Skip to content

WidgetTopOffersByPrincipalsLastNyearsComponent

reference
2 min readUpdated

Kind: Class

Source: Frontend/src/app/components/dashboard/dashboard-libary/widgets/widget-top-offers-by-principals-last-nyears/widget-top-offers-by-principals-last-nyears.component.ts (line 22)

Part of: Frontend

WidgetTopOffersByPrincipalsLastNyearsComponent displays dashboard data for top offers grouped by principal across a configured range of years. It checks feature subscription access, retrieves dashboard data, processes responses, and initializes the related chart during Angular lifecycle updates.

Extends: BaseWidgetComponent

Implements: OnInit

Methods

MethodSignatureReturns
viewDataviewData()void
initializeChartinitializeChart(seriesData: undefined, headerData: undefined)void
checkFeatureSubscriptioncheckFeatureSubscription()boolean
getDashboardDatagetDashboardData()void
afterResponseafterResponse(Data: any[])void
ngOnChangesngOnChanges()void
ngOnInitngOnInit()void
setYearColorsetYearColor(year: number)string
onChartInitonChartInit(e: any)void
onPlannedVisitsChartClickonPlannedVisitsChartClick(e: undefined)void
setChachingsetChaching()void
getChachinggetChaching()void
onValueChangedonValueChanged(e: undefined)void
switchChartTypeHandlerswitchChartTypeHandler()void
switchChartRefernceCommissionHandlerswitchChartRefernceCommissionHandler()void
toggoleOnlyCurrentOfferstoggoleOnlyCurrentOffers()void
toggoleBudgetOfferstoggoleBudgetOffers()void
toggoleFirmOfferstoggoleFirmOffers()void
switchFirmOffersswitchFirmOffers()void
switchBudgetOffersswitchBudgetOffers()void
nextPagenextPage()void
prevPageprevPage()void

Properties

PropertyType
_widgetWidget
meAsVendorboolean
isRefernceCommissionboolean
withoutOptionBarboolean
onlyCurrentOffersboolean
numYearsnumber
_FirmOffersboolean
_BudgetOffersboolean
numYearsDatasourceany[]
todayWidgetsEnumany
branchNamestring
maxValueForYaxisnumber
initOptsany
seriesany[]
headerany[]
echartsIntanceany
cachingWidgetDataCachingWidgetData
originalDatasourceWidgetTopOffers[]
datasourceWidgetTopOffers[]
originalHeaderany[]
optionsany
skipnumber
currenFeaturenumber
seriesDataany
headerDataany[]
showDataOnChartboolean

Where it refuses work

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

Diagram

mermaid
graph LR
  Lifecycle[Angular lifecycle] --> Init[ngOnInit]
  Lifecycle --> Changes[ngOnChanges]
  Init --> Subscription[checkFeatureSubscription]
  Changes --> Subscription
  Subscription -->|Allowed| Data[getDashboardData]
  Data --> Response[afterResponse]
  Response --> Chart[initializeChart]
  Chart --> ChartReady[onChartInit]
  Chart --> YearColor[setYearColor]
  ChartReady --> Click[onPlannedVisitsChartClick]
  Data --> View[viewData]

Usage

ts
import { Component, ViewChild } from '@angular/core';
import { WidgetTopOffersByPrincipalsLastNyearsComponent } from './widget-top-offers-by-principals-last-nyears.component';

@Component({
  selector: 'app-dashboard-page',
  template: `
    <app-widget-top-offers-by-principals-last-nyears
      #topOffersWidget>
    </app-widget-top-offers-by-principals-last-nyears>
  `
})
export class DashboardPageComponent {
  @ViewChild('topOffersWidget')
  topOffersWidget?: WidgetTopOffersByPrincipalsLastNyearsComponent;

  refreshTopOffers(): void {
    const widget = this.topOffersWidget;

    if (widget?.checkFeatureSubscription()) {
      widget.getDashboardData();
    }
  }
}

AI Coding Instructions

  • Keep data retrieval behind checkFeatureSubscription() so unavailable features do not request or render dashboard data.
  • Let ngOnInit() and ngOnChanges() coordinate initialization and updates; do not call lifecycle hooks directly from application code.
  • Process API results through afterResponse() before initializing or updating chart state.
  • Keep chart setup in initializeChart() and chart event handling in onChartInit() and onPlannedVisitsChartClick().
  • Use setYearColor() when assigning series colors so year-based chart styling remains consistent.

Used by

2 references from 2 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (2)

  • WidgetTopOffersByVariantsComponentFrontend/src/app/components/dashboard/dashboard-libary/widgets/widget-top-offers-by-variants/widget-top-offers-by-variants.component.ts:1
  • DashboardWidgetsModuleFrontend/src/app/components/dashboard/dashboard-widgets.module.ts:1

Was this page helpful?

Download as PDF