# WidgetTopOffersByTeamsLastNyearsComponent

**Kind:** Class

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

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

`WidgetTopOffersByTeamsLastNyearsComponent` is an Angular dashboard widget that loads and displays top offers grouped by teams for the selected year range. It manages lifecycle updates, chart initialization and click handling, year-based coloring, and cached widget settings.

**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
  A[ngOnInit / ngOnChanges] --> B[getChaching]
  B --> C[getDashboardData]
  C --> D[afterResponse]
  D --> E[onChartInit]
  E --> F[setYearColor]
  G[onValueChanged] --> H[setChaching]
  H --> C
  I[onPlannedVisitsChartClick] --> C
```

## Usage

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

@Component({
  selector: 'app-dashboard-host',
  template: `
    <app-widget-top-offers-by-teams-last-nyears></app-widget-top-offers-by-teams-last-nyears>

    <button type="button" (click)="refreshOffers()">
      Refresh offers
    </button>
  `
})
export class DashboardHostComponent {
  @ViewChild(WidgetTopOffersByTeamsLastNyearsComponent)
  offersWidget!: WidgetTopOffersByTeamsLastNyearsComponent;

  refreshOffers(): void {
    this.offersWidget.getDashboardData();
  }

  handleYearChange(): void {
    this.offersWidget.onValueChanged();
  }
}
```

## AI Coding Instructions

- Keep data loading in `getDashboardData()` and handle transformed response state in `afterResponse()`.
- Preserve the Angular lifecycle flow through `ngOnInit()` and `ngOnChanges()` when adding input-driven behavior.
- Initialize or update chart bindings through `onChartInit()` after dashboard data is available.
- Keep the existing `setChaching()` and `getChaching()` method names when working with cached widget settings.
- Route chart click behavior through `onPlannedVisitsChartClick()` rather than adding duplicate chart event handlers.

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