Skip to content

WidgetForecastVsTargetThisYearComponent

reference
1 min readUpdated

Kind: Class

Source: Frontend/src/app/components/dashboard/dashboard-libary/widgets/widget-forecast-vs-target-this-year/widget-forecast-vs-target-this-year.component.ts (line 30)

Part of: Frontend

WidgetForecastVsTargetThisYearComponent manages the dashboard widget that compares this year's forecast against its target. It checks subscription access, loads dashboard data, prepares chart values, formats pricing, and responds to forecast or chart-type switches.

Extends: BaseWidgetComponent

Implements: OnInit

Methods

MethodSignatureReturns
ngOnInitngOnInit()void
checkFeatureSubscriptioncheckFeatureSubscription()boolean
getDashboardDatagetDashboardData()void
initalizingDatainitalizingData(value: MonthData[])void
getpriceFormattedgetpriceFormatted(x: undefined)string
calculatForecastVsTargetcalculatForecastVsTarget(value: MonthData)number
switchIsForecastHandlerswitchIsForecastHandler()void
switchChartTypeHandlerswitchChartTypeHandler()void
onChartInitonChartInit(e: any, index: number)void
setValuesetValue(value: number)void

Properties

PropertyType
_widgetWidget
withNominalboolean
selectedYearnumber
todayWidgetsEnumany
BranchesBranchessTendancy[]
MonthDataMonthData[]
IsForecastboolean
initOptsany
seriesany[]
headerDataany
echartsIntanceany
optionsany
TargetBooking`string
AchievedBooking`string
currenFeaturenumber

Where it refuses work

  • WidgetForecastVsTargetThisYearComponent stops the work with an early return when this.dashboardLibraryService.checkFeatureSubscription(this.widget.chartEnumId).

Diagram

mermaid
graph LR
  Dashboard[Dashboard] --> Widget[WidgetForecastVsTargetThisYearComponent]
  Widget --> Subscription[checkFeatureSubscription]
  Widget --> Data[getDashboardData]
  Data --> Initialize[initalizingData]
  Initialize --> Calculation[calculatForecastVsTarget]
  Calculation --> Chart[onChartInit]
  Widget --> ForecastSwitch[switchIsForecastHandler]
  Widget --> ChartSwitch[switchChartTypeHandler]
  Widget --> Formatting[getpriceFormatted]
  Widget --> Values[setValue]

Usage

ts
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { WidgetForecastVsTargetThisYearComponent } from './widget-forecast-vs-target-this-year.component';

describe('WidgetForecastVsTargetThisYearComponent', () => {
  let fixture: ComponentFixture<WidgetForecastVsTargetThisYearComponent>;
  let component: WidgetForecastVsTargetThisYearComponent;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [WidgetForecastVsTargetThisYearComponent],
    }).compileComponents();

    fixture = TestBed.createComponent(WidgetForecastVsTargetThisYearComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('loads and updates forecast data', () => {
    component.ngOnInit();

    if (component.checkFeatureSubscription()) {
      component.getDashboardData();
      component.switchIsForecastHandler();
      component.switchChartTypeHandler();

      const formattedPrice = component.getpriceFormatted();
      const forecastVsTarget = component.calculatForecastVsTarget();

      expect(formattedPrice).toBeDefined();
      expect(forecastVsTarget).toBeDefined();
    }
  });
});

AI Coding Instructions

  • Keep subscription checks in place before requesting or displaying widget data.
  • Call initalizingData() after dashboard data is available so chart values reflect the current response.
  • Update chart state through switchIsForecastHandler(), switchChartTypeHandler(), and setValue() rather than changing chart-related fields directly.
  • Preserve the existing getpriceFormatted() and calculatForecastVsTarget() behavior when changing displayed values.

Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (1)

  • DashboardWidgetsModuleFrontend/src/app/components/dashboard/dashboard-widgets.module.ts:1

Was this page helpful?

Download as PDF