---
title: Widget reference
project: Tableau de bord
version: 1.0
section: development
language: fr
translation: missing
license: Total.js Enterprise
url: https://totaljs.es/docs/fr/dashboard/1-0/development/widget-api/
updated: 2026-11-20T06:52:02.970Z
---

# Widget reference

> The keys and functions of a widget file, in the server part and in the browser part.

A widget file sets keys on `exports` in two places: in `<script total>` on the server, and in the `<script>` of `<body>` in the browser. See [Custom widgets](../custom-widgets/) for a whole file.

Entries of type **property** are keys you set. Entries of type **event** are functions you define and Dashboard calls. Entries of type **method** are functions that Dashboard gives you.

## API

### exports.name = 'Total';

Type: `property`

The name of the widget in the Widgets window and the first title of a new widget.

Set it in `<script total>`.

### exports.icon = 'ti ti-calculator';

Type: `property`

The icon of the widget in the Widgets window.

A Total.js icon class. Set it in `<script total>`.

### exports.color = '#34A853';

Type: `property`

The colour of the icon in the Widgets window.

Set it in `<script total>`.

### exports.config = { dataset: [], interval: 0 };

Type: `property`

The settings of a new widget.

Set it in `<script total>`. The settings form edits these keys, and `exports.make` receives them as `config`.

### exports.hidden = true;

Type: `property`

Keeps the widget out of the Widgets window.

Use it for a file that only adds a [data source](../data-sources/). Set it in `<script total>`.

### exports.install = function(dashboard) {}

Type: `event`

Runs on the server when the widget is loaded.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `dashboard` | `Object` | yes |  | The dashboard on the server. See [Data sources](../data-sources/). |

Register [data sources](../data-sources/) here with `dashboard.source()`.

### exports.uninstall = function(dashboard) {}

Type: `event`

Runs on the server before the widget is replaced or removed.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `dashboard` | `Object` | yes |  | The dashboard on the server. |

Remove here what `exports.install` registered, for example with `dashboard.source(name, null)`.

### exports.offset = { lg: { width: 3, height: 2 }, md: { width: 4, height: 3 }, xs: { width: 6, height: 3 } };

Type: `property`

The size of a new widget on the grid, for large, medium and extra small screens.

Width and height are in cells of the grid. The grid is 12 cells wide. Set it in the browser part.

### exports.actions = { move: true, remove: true, resize: true, resizeX: true, resizeY: true, settings: true };

Type: `property`

What people may do with the widget on the dashboard.

`move` lets them drag it, `resize`, `resizeX` and `resizeY` let them resize it, `remove` shows the bin icon and `settings` shows the gear icon. Set it in the browser part.

### exports.header = true;

Type: `property`

Shows the title bar of the widget.

Set it in the browser part.

### exports.import = ['https://cdnjs.cloudflare.com/ajax/libs/apexcharts/3.54.1/apexcharts.min.js'];

Type: `property`

Scripts and style sheets that the widget needs.

Dashboard loads each address once, before it draws the dashboard. Set it in the browser part.

### exports.make = function(instance, config, element) {}

Type: `event`

Draws one widget on the dashboard.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `instance` | `Object` | yes |  | The widget on the dashboard. |
| `config` | `Object` | yes |  | The settings of the widget. |
| `element` | `jQuery` | yes |  | The element to draw into. |

Dashboard calls it for each widget of this type. Define the handlers of `instance` here and draw the first content.

### instance.dataset(item, callback)

Type: `method`

Loads the chart data of one entry of the Dataset setting.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `item` | `Object` | yes |  | One entry of `config.dataset`. |
| `callback` | `Function` | yes |  | `function(response)` with the list of series. |

The callback receives a list of series. Each series has `id`, `name`, `icon`, `color`, `format`, `decimals` and `data`, a list of points with `x` and `y`. See [Chart data](../../guides/chart-data/).

Example: Load the first report of the settings
```js
instance.dataset(config.dataset[0], function(response) {
	for (var serie of response)
		console.log(serie.name, serie.data.length);
});
```

### instance.configure = function() {}

Type: `event`

Runs after someone saves the settings of the widget.

Reload the data here, because `config` now holds the new settings.

### instance.service = function(counter) {}

Type: `event`

Runs every second while the dashboard is open.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `counter` | `Number` | yes |  | The number of seconds since the dashboard opened. |

Use it for a refresh interval: reload when `counter % config.interval === 0`.
