# WidgetTopOffersByMarketSegmentsLastNyearsComponent

**Kind:** Class

**Source:** `Pams/Web/Pams.Web/Client/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 22)

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

`WidgetTopOffersByMarketSegmentsLastNyearsComponent` is an Angular dashboard widget that loads and displays top offers grouped by market segment across a selected year range. It reacts to lifecycle and value changes, initializes chart behavior, handles chart clicks, assigns year colors, and stores or retrieves 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` |
| `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
    Inputs --> ngOnChanges
    ngOnInit --> getChaching
    getChaching --> getDashboardData
    ngOnChanges --> getDashboardData
    onValueChanged --> setChaching
    onValueChanged --> getDashboardData
    getDashboardData --> afterResponse
    afterResponse --> Chart
    onChartInit --> Chart
    setYearColor --> Chart
    Chart --> onPlannedVisitsChartClick
```

## Usage

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

@Component({
  selector: 'app-dashboard-host',
  template: `
    <app-widget-top-offers-by-market-segments-last-nyears>
    </app-widget-top-offers-by-market-segments-last-nyears>
  `
})
export class DashboardHostComponent implements AfterViewInit {
  @ViewChild(WidgetTopOffersByMarketSegmentsLastNyearsComponent)
  offersWidget!: WidgetTopOffersByMarketSegmentsLastNyearsComponent;

  ngAfterViewInit(): void {
    this.offersWidget.getChaching();
    this.offersWidget.getDashboardData();
  }

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

## AI Coding Instructions

- Keep data loading in `getDashboardData()` and apply response-dependent state updates in `afterResponse()`.
- Call `setChaching()` when widget selections change so cached state matches the current chart state.
- Use `getChaching()` during initialization before requesting dashboard data when cached selections are supported.
- Keep chart setup in `onChartInit()` and route chart interaction handling through `onPlannedVisitsChartClick()`.
- Use `setYearColor()` for chart series colors rather than assigning year colors in multiple locations.

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