Skip to content

WidgetTopOffersByMarketSegmentsLastNyearsComponent

reference
2 min readUpdated

Kind: Class

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

Part of: Frontend

WidgetTopOffersByMarketSegmentsLastNyearsComponent is an Angular dashboard widget that retrieves and presents top offers grouped by market segments across recent years. It coordinates dashboard data loading, chart initialization, feature-subscription checks, chart styling, and chart interaction handling.

Extends: BaseWidgetComponent

Implements: OnInit

Methods

MethodSignatureReturns
viewDataviewData()void
getDashboardDatagetDashboardData()void
initializeChartinitializeChart(seriesData: undefined, headerData: undefined)void
afterResponseafterResponse(Data: any[])void
checkFeatureSubscriptioncheckFeatureSubscription()boolean
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

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

Diagram

mermaid
graph LR
  A[ngOnInit / ngOnChanges] --> B[checkFeatureSubscription]
  B -->|Subscribed| C[getDashboardData]
  B -->|Not subscribed| D[viewData]
  C --> E[afterResponse]
  E --> F[initializeChart]
  F --> G[onChartInit]
  G --> H[setYearColor]
  G --> I[onPlannedVisitsChartClick]

Usage

ts
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { WidgetTopOffersByMarketSegmentsLastNyearsComponent } from './widget-top-offers-by-market-segments-last-nyears.component';

let fixture: ComponentFixture<WidgetTopOffersByMarketSegmentsLastNyearsComponent>;
let component: WidgetTopOffersByMarketSegmentsLastNyearsComponent;

beforeEach(() => {
  TestBed.configureTestingModule({
    declarations: [WidgetTopOffersByMarketSegmentsLastNyearsComponent],
  });

  fixture = TestBed.createComponent(
    WidgetTopOffersByMarketSegmentsLastNyearsComponent,
  );

  component = fixture.componentInstance;
  fixture.detectChanges();
});

it('loads dashboard data when the feature is available', () => {
  if (component.checkFeatureSubscription()) {
    component.getDashboardData();
  }

  expect(component).toBeTruthy();
});

AI Coding Instructions

  • Call checkFeatureSubscription() before requesting or rendering dashboard data that depends on the related feature.
  • Keep data-response processing in afterResponse() and chart setup in initializeChart() rather than mixing them into lifecycle methods.
  • Handle input-driven refresh behavior through ngOnChanges() and initial loading through ngOnInit().
  • Use setYearColor() for year-based chart colors so chart styling remains consistent.
  • Route chart click behavior through onPlannedVisitsChartClick() instead of attaching duplicate click handling outside the component.

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