# WidgetTopOffersByPrincipalsLastNyearsComponent

**Kind:** Class

**Source:** `Pams/Web/Pams.Web/Client/app/components/dashboard/dashboard-libary/widgets/widget-top-offers-by-principals-last-nyears/widget-top-offers-by-principals-last-nyears.component.ts` (line 23)

**Part of:** [Pams](subsystem-pams)

`WidgetTopOffersByPrincipalsLastNyearsComponent` manages dashboard data for the top offers by principals view across recent years. It coordinates data retrieval, response handling, chart setup and interactions, year color selection, caching, and value-change updates.

**Implements:** `OnInit`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `getDashboardData` | `getDashboardData()` | `void` |
| `afterResponse` | `afterResponse(Data: any[])` | `void` |
| `ngOnChanges` | `ngOnChanges()` | `void` |
| `ngOnInit` | `ngOnInit()` | `void` |
| `setYearColor` | `setYearColor(year: number)` | `string` |
| `onChartInit` | `onChartInit(e: any)` | `void` |
| `onPlannedVisitsChartClick` | `onPlannedVisitsChartClick(e: undefined)` | `void` |
| `setChaching` | `setChaching()` | `void` |
| `getChaching` | `getChaching()` | `void` |
| `onValueChanged` | `onValueChanged(e: undefined)` | `void` |
| `switchChartTypeHandler` | `switchChartTypeHandler()` | `void` |
| `switchChartRefernceCommissionHandler` | `switchChartRefernceCommissionHandler()` | `void` |
| `toggoleOnlyCurrentOffers` | `toggoleOnlyCurrentOffers()` | `void` |
| `toggoleBudgetOffers` | `toggoleBudgetOffers()` | `void` |
| `toggoleFirmOffers` | `toggoleFirmOffers()` | `void` |
| `switchFirmOffers` | `switchFirmOffers()` | `void` |
| `switchBudgetOffers` | `switchBudgetOffers()` | `void` |
| `nextPage` | `nextPage()` | `void` |
| `prevPage` | `prevPage()` | `void` |
| `ngOnDestroy` | `ngOnDestroy()` | `void` |

## Properties

| Property | Type |
|---|---|
| `_widget` | `Widget` |
| `meAsVendor` | `boolean` |
| `isRefernceCommission` | `boolean` |
| `withoutOptionBar` | `boolean` |
| `onlyCurrentOffers` | `boolean` |
| `numYears` | `number` |
| `_FirmOffers` | `boolean` |
| `_BudgetOffers` | `boolean` |
| `numYearsDatasource` | `any[]` |
| `todayWidgetsEnum` | `any` |
| `subscription` | `Subscription` |
| `branchName` | `string` |
| `maxValueForYaxis` | `number` |
| `initOpts` | `any` |
| `series` | `any[]` |
| `headerData` | `any[]` |
| `echartsIntance` | `any` |
| `cachingWidgetData` | `CachingWidgetData` |
| `originalDatasource` | `WidgetTopOffers[]` |
| `datasource` | `WidgetTopOffers[]` |
| `originalHeader` | `any[]` |
| `options` | `any` |
| `skip` | `number` |

## Diagram

```mermaid
graph LR
  AngularLifecycle[Angular lifecycle] --> ngOnInit
  AngularLifecycle --> ngOnChanges
  ngOnInit --> getDashboardData
  ngOnChanges --> getDashboardData
  getDashboardData --> afterResponse
  afterResponse --> setYearColor
  afterResponse --> onChartInit
  onChartInit --> Chart[Offers chart]
  Chart --> onPlannedVisitsChartClick
  ValueChange[Value change] --> onValueChanged
  onValueChanged --> setChaching
  getChaching --> getDashboardData
```

## Usage

```ts
import { WidgetTopOffersByPrincipalsLastNyearsComponent } from './widget-top-offers-by-principals-last-nyears.component';

export function refreshTopOffers(
  widget: WidgetTopOffersByPrincipalsLastNyearsComponent
): void {
  widget.getChaching();
  widget.getDashboardData();
}

export function persistSelectedValue(
  widget: WidgetTopOffersByPrincipalsLastNyearsComponent
): void {
  widget.onValueChanged();
  widget.setChaching();
}
```

## AI Coding Instructions

- Use `getDashboardData()` as the entry point when the widget needs refreshed dashboard content.
- Keep response-specific chart preparation in `afterResponse()` and initialize chart bindings through `onChartInit()`.
- Let Angular invoke `ngOnInit()` and `ngOnChanges()` rather than calling lifecycle hooks from application code.
- Preserve the existing `setChaching()` and `getChaching()` method names when changing cache behavior.
- Keep chart click behavior inside `onPlannedVisitsChartClick()` so chart event handling remains localized.

## 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)

- `TranslateHandler` — `Pams/Web/Pams.Web/Client/app/app.module.ts`:1
- `WidgetTopOffersByVariantsComponent` — `Pams/Web/Pams.Web/Client/app/components/dashboard/dashboard-libary/widgets/widget-top-offers-by-variants/widget-top-offers-by-variants.component.ts`:1
