# WidgetTopOffersByClientsLastNyearsComponent

**Kind:** Class

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

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

`WidgetTopOffersByClientsLastNyearsComponent` is an Angular dashboard widget that retrieves and presents top offers grouped by client over a recent-year range. It manages widget lifecycle events, chart initialization and click handling, year-based coloring, value changes, and cached widget state.

**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` |
| `toggoleOnlyCurrentOffers` | `toggoleOnlyCurrentOffers()` | `void` |
| `switchChartRefernceCommissionHandler` | `switchChartRefernceCommissionHandler()` | `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` |
| `numYearsDatasource` | `any[]` |
| `_FirmOffers` | `boolean` |
| `_BudgetOffers` | `boolean` |
| `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
    Dashboard[Dashboard inputs] --> Changes[ngOnChanges]
    Init[ngOnInit] --> Data[getDashboardData]
    Changes --> Data
    Value[onValueChanged] --> Data
    Data --> Response[afterResponse]
    Response --> Chart[onChartInit]
    Chart --> Click[onPlannedVisitsChartClick]
    Response --> Colors[setYearColor]
    CacheGet[getChaching] --> Data
    Data --> CacheSet[setChaching]
```

## Usage

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

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

  refreshTopOffers(): void {
    this.topOffersWidget?.getDashboardData();
  }
}
```

## AI Coding Instructions

- Let Angular invoke `ngOnInit` and `ngOnChanges`; do not call lifecycle hooks directly from application code.
- Keep data loading in `getDashboardData()` and process returned data through `afterResponse()`.
- Preserve the existing `setChaching()` and `getChaching()` method names when working with cached widget state.
- Initialize chart event wiring in `onChartInit()` and keep chart click behavior in `onPlannedVisitsChartClick()`.
- When adding filter inputs or dashboard controls, route updates through `onValueChanged()` so the widget reloads consistently.

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