# DashboardWidget

**Kind:** Class

**Source:** `Pams/Web/Pams.Web/Client/app/models/dashboard/dashboard-widget.model.ts` (line 10)

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

`DashboardWidget` models a dashboard widget and coordinates its labels, data source state, color settings, schema, selections, and chart data. It is used by dashboard UI code to rebuild widget state when data or display configuration changes.

## Methods

| Method | Signature | Returns |
|---|---|---|
| `syncLabels` | `syncLabels(source: Array<string>)` | `void` |
| `DataSourceChanged` | `DataSourceChanged()` | `void` |
| `ChangeColor` | `ChangeColor(serial: string, value: string)` | `void` |
| `UpdateColors` | `UpdateColors()` | `void` |
| `BuildSchema` | `BuildSchema()` | `void` |
| `CombaineSelection` | `CombaineSelection()` | `void` |
| `updateChartsColor` | `updateChartsColor()` | `void` |
| `createPieData` | `createPieData(dataSource: undefined, chart: undefined)` | `void` |

## Properties

| Property | Type |
|---|---|
| `ID` | `number` |
| `PrimaryID` | `number` |
| `FilterEditingObject` | `FilterEditingObject[]` |
| `DisplayID` | `string` |
| `Caption` | `string` |
| `DatasourceInit` | `any[]` |
| `Datasource` | `any` |
| `OrginalDatasource` | `any` |
| `MasterFilter` | `boolean` |
| `AcceptFilter` | `any[]` |
| `charts` | `any` |
| `FilterString` | `string` |
| `FilterSelectionType` | `string` |
| `ChartSeriseSelectionType` | `string` |
| `CurrentData` | `any` |
| `table` | `Table` |
| `view` | `View` |
| `isTable` | `boolean` |
| `CenterRange` | `boolean` |
| `Operations` | `any[]` |
| `DataOperations` | `DashboardDataFields[]` |
| `IsSelected` | `boolean` |
| `isNested` | `boolean` |
| `Stacked` | `boolean` |
| `ExpBar` | `boolean` |
| `selectedArgument` | `Array<DimensionField>` |
| `selectedSerise` | `Array<DimensionField>` |
| `AutoColoredMeasure` | `boolean` |
| `ColorschemaList` | `Array<schema>` |
| `colorCounter` | `number` |
| `colorPlatte` | `any[]` |
| `Item` | `GridStackItem` |
| `WidgetType` | `DashboardWidgetTypeEnum` |
| `GridStackMainWidth` | `number` |
| `ColorContext` | `any` |
| `ColorBehavior` | `boolean` |
| `widgetLabels` | `Array<{label:string ,priority:number}>` |
| `ColumnFields` | `any[]` |
| `ValueFields` | `any[]` |
| `GroupByFields` | `any[]` |
| `XaxisFields` | `any[]` |
| `YaxisFields` | `any[]` |

## Where it refuses work

- `DashboardWidget` stops the work with an early return when `inx == all_Fields.length`.

## Diagram

```mermaid
graph LR
  DataSource[Data source change] --> DataSourceChanged
  DataSourceChanged --> BuildSchema
  BuildSchema --> CombaineSelection
  CombaineSelection --> createPieData
  Labels[Label updates] --> syncLabels
  Colors[Color changes] --> ChangeColor
  ChangeColor --> UpdateColors
  UpdateColors --> updateChartsColor
  createPieData --> Chart[Chart rendering]
  updateChartsColor --> Chart
```

## Usage

```ts
import { DashboardWidget } from './models/dashboard/dashboard-widget.model';

function refreshDashboardWidget(widget: DashboardWidget): void {
  widget.DataSourceChanged();
  widget.BuildSchema();
  widget.CombaineSelection();

  widget.syncLabels();
  widget.UpdateColors();
  widget.updateChartsColor();

  widget.createPieData();
}
```

## AI Coding Instructions

- Call `DataSourceChanged()` before rebuilding schema or chart data after the widget's data source changes.
- Keep label updates in `syncLabels()` so displayed labels remain aligned with widget configuration.
- Use `ChangeColor()`, `UpdateColors()`, and `updateChartsColor()` together when changing chart colors.
- Rebuild selection state with `CombaineSelection()` before generating data through `createPieData()`.
- Preserve the existing method naming when integrating with callers, including `CombaineSelection()`.

## Relationships

- IMPORTS → `DashboardWidgetTypeEnum`
- IMPORTS → `Table`
- IMPORTS → `View`
- IMPORTS → `platte`
- IMPORTS → `Query`
- IMPORTS → `DashboardDataFields`
- IMPORTS → `DataTypeEnum`
- IMPORTS → `OperationTypeEnum`
- IMPORTS → `QueryTypeEnum`
- IMPORTS → `chartType`
- IMPORTS → `DimensionField`

## Used by

6 references from 6 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (6)

- `GridBarChartComponent` — `Pams/Web/Pams.Web/Client/app/components/shared/grid-bar-chart/grid-bar-chart.component.ts`:1
- `PamsBarChartComponent` — `Pams/Web/Pams.Web/Client/app/components/shared/pams-bar-chart/pams-bar-chart.component.ts`:1
- `PamsPieChartComponent` — `Pams/Web/Pams.Web/Client/app/components/shared/pams-pie-chart/pams-pie-chart.component.ts`:1
- `DashboardWidgetOperationsService` — `Pams/Web/Pams.Web/Client/app/services/dashboard/dashboard-widget-operations.service.ts`:1
- `DashboardGroup` — `Pams/Web/Pams.Web/Client/app/models/dashboard/dashboard-group.model.ts`:2
- `Operations` — `Pams/Web/Pams.Web/Client/app/components/dashboard/dashboard-operations.ts`:15
