---
title: "Flash On Update"
enterprise: true
framework: javascript
version: "14.1.0"
---

# Flash On Update

Flash on Update signals that chart data has changed by briefly overlaying a flash animation, drawing the user's attention to the chart whenever data is updated, added or removed.

## Enabling Flash On Update

Flash on Update is disabled by default. To enable it, set `flashOnUpdate.enabled` to `true`.

#### Flash On Update

```ts
import {
  AgCartesianChartOptions,
  AgCharts,
  CandlestickSeriesModule,
  ContextMenuModule,
  CrosshairModule,
  FlashOnUpdateModule,
  LegendModule,
  ModuleRegistry,
  NumberAxisModule,
  OrdinalTimeAxisModule,
} from "ag-charts-enterprise";
import { applyLiveUpdate, getInitialData } from "./data";

ModuleRegistry.registerModules([
  CandlestickSeriesModule,
  ContextMenuModule,
  CrosshairModule,
  FlashOnUpdateModule,
  LegendModule,
  NumberAxisModule,
  OrdinalTimeAxisModule,
]);

const options: AgCartesianChartOptions = {
  data: getInitialData(),
  title: {
    text: "AAPL Stock Price",
  },
  series: [
    {
      type: "candlestick",
      xKey: "date",
      xName: "Date",
      openKey: "open",
      highKey: "high",
      lowKey: "low",
      closeKey: "close",
    },
  ],
  axes: {
    y: {
      type: "number",
      label: {
        formatter: ({ value }) => `$${Number(value).toFixed(0)}`,
      },
    },
  },
  flashOnUpdate: {
    enabled: true,
  },
};

options.container = document.getElementById("myChart");

const chart = AgCharts.create(options);

function update() {
  options.data = applyLiveUpdate(options.data!);

  chart.update(options);
}

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).update = update;
}
```

[Live example: Flash On Update](https://www.ag-grid.com/charts/typescript/flash-on-update/examples/flash-on-update)

```js
{
    flashOnUpdate: {
        enabled: true,
    },
}
```

## Category Flash

Flashing just the category band makes it easier to identify which categories have changed. Set `item` to `'category'` to enable this.

#### Category Flash

```ts
import {
  BarSeriesModule,
  CategoryAxisModule,
  LegendModule,
  ModuleRegistry,
  NumberAxisModule,
} from "ag-charts-community";
import {
  AgCartesianChartOptions,
  AgCharts,
  ContextMenuModule,
  CrosshairModule,
  FlashOnUpdateModule,
} from "ag-charts-enterprise";
import { DataType, applyRandomUpdate, getInitialData } from "./data";

let data: DataType[] = getInitialData();
let isRunning = false;
let updateInterval: ReturnType<typeof setInterval> | undefined;
ModuleRegistry.registerModules([
  BarSeriesModule,
  CategoryAxisModule,
  ContextMenuModule,
  CrosshairModule,
  FlashOnUpdateModule,
  LegendModule,
  NumberAxisModule,
]);

const options: AgCartesianChartOptions<DataType> = {
  data,
  title: {
    text: "Stock Trading Volume",
  },
  series: [
    {
      type: "bar",
      xKey: "ticker",
      yKey: "buyVolume",
      yName: "Buy Volume (M)",
      stacked: true,
    },
    {
      type: "bar",
      xKey: "ticker",
      yKey: "sellVolume",
      yName: "Sell Volume (M)",
      stacked: true,
    },
  ],
  axes: {
    x: {
      type: "category",
      label: {
        autoRotate: false,
      },
    },
  },
  flashOnUpdate: {
    enabled: true,
    item: "category",
  },
};

options.container = document.getElementById("myChart");

const chart = AgCharts.create(options);

function update() {
  data = applyRandomUpdate(data);
  options.data = data;

  chart.update(options);
}

function startUpdates() {
  if (isRunning) return;
  isRunning = true;
  updateButton();
  update();
  updateInterval = setInterval(update, 2000);
}

function stopUpdates() {
  if (!isRunning) return;
  isRunning = false;
  updateButton();
  if (updateInterval) {
    clearInterval(updateInterval);
    updateInterval = undefined;
  }
}

function updateButton() {
  const button = document.getElementById("toggleBtn");
  if (button) {
    button.textContent = isRunning ? "Stop Updates" : "Start Updates";
  }
}

function toggleUpdates() {
  if (isRunning) {
    stopUpdates();
  } else {
    startUpdates();
  }
}

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).toggleUpdates = toggleUpdates;
}
```

[Live example: Category Flash](https://www.ag-grid.com/charts/typescript/flash-on-update/examples/flash-on-update-category)

```js
{
    flashOnUpdate: {
        enabled: true,
        item: 'category',
    },
}
```

In this example:

- Click 'Start Updates' to begin a simulated data feed that updates 1–3 bars every 2 seconds.
- Only the changed bars flash.
- Click **Stop Updates** to pause the feed.
- Category Flash is only available on [Category](https://www.ag-grid.com/charts/javascript/axes-types/#category), [Grouped Category](https://www.ag-grid.com/charts/javascript/axes-types/#grouped-category), [Unit Time](https://www.ag-grid.com/charts/javascript/axes-time/#unit-time) and [Ordinal Time](https://www.ag-grid.com/charts/javascript/axes-time/#ordinal-time) axes.

### Adding and Removing Data

Category flash is also triggered when a category is added to the chart. Removing a category does not trigger a flash.

#### Adding and Removing Data

```ts
import {
  BarSeriesModule,
  CategoryAxisModule,
  LegendModule,
  ModuleRegistry,
  NumberAxisModule,
} from "ag-charts-community";
import {
  AgCartesianChartOptions,
  AgCharts,
  ContextMenuModule,
  CrosshairModule,
  FlashOnUpdateModule,
} from "ag-charts-enterprise";
import { DataType, applyUpdate, getInitialData, getNextSector } from "./data";

ModuleRegistry.registerModules([
  BarSeriesModule,
  CategoryAxisModule,
  ContextMenuModule,
  CrosshairModule,
  FlashOnUpdateModule,
  LegendModule,
  NumberAxisModule,
]);

const options: AgCartesianChartOptions<DataType> = {
  data: getInitialData(),
  title: {
    text: "Sector Trading Activity",
  },
  series: [
    {
      type: "bar",
      xKey: "sector",
      yKey: "institutional",
      yName: "Institutional ($M)",
      stacked: true,
    },
    {
      type: "bar",
      xKey: "sector",
      yKey: "retail",
      yName: "Retail ($M)",
      stacked: true,
    },
    {
      type: "bar",
      xKey: "sector",
      yKey: "etfFlows",
      yName: "ETF Flows ($M)",
      stacked: true,
    },
  ],
  axes: {
    x: {
      type: "category",
    },
  },
  flashOnUpdate: {
    enabled: true,
    item: "category",
  },
};

options.container = document.getElementById("myChart");

const chart = AgCharts.create(options);

function addSector() {
  const next = getNextSector(options.data!);
  if (!next) return;
  options.data = [...options.data!, { ...next }];

  chart.update(options);
}

function removeSector() {
  if (options.data!.length <= 2) return;
  options.data = options.data!.slice(0, -1);

  chart.update(options);
}

function updateSectors() {
  options.data = applyUpdate(options.data!);

  chart.update(options);
}

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).addSector = addSector;
  (<any>window).removeSector = removeSector;
  (<any>window).updateSectors = updateSectors;
}
```

[Live example: Adding and Removing Data](https://www.ag-grid.com/charts/typescript/flash-on-update/examples/flash-on-update-add-remove)

In this example:

- Click 'Add Sector' to add a new sector to the chart — the new category flashes on arrival.
- Click 'Remove Sector' to remove the last sector — no flash occurs on removal.
- Click 'Update' to update values for one or two sectors and observe the category flash.

## Customisation

The appearance and timing of the flash effect can be customised.

#### Customisation

```ts
import {
  AgCartesianChartOptions,
  AgCharts,
  ContextMenuModule,
  CrosshairModule,
  FlashOnUpdateModule,
  LegendModule,
  ModuleRegistry,
  NumberAxisModule,
  OhlcSeriesModule,
  OrdinalTimeAxisModule,
} from "ag-charts-enterprise";
import { applyLiveUpdate, getInitialData } from "./data";

let data = getInitialData();
let isRunning = false;
let updateInterval: ReturnType<typeof setInterval> | undefined;
ModuleRegistry.registerModules([
  ContextMenuModule,
  CrosshairModule,
  FlashOnUpdateModule,
  LegendModule,
  NumberAxisModule,
  OhlcSeriesModule,
  OrdinalTimeAxisModule,
]);

const options: AgCartesianChartOptions = {
  data,
  title: {
    text: "MSFT Stock Price",
  },
  series: [
    {
      type: "ohlc",
      xKey: "date",
      xName: "Date",
      openKey: "open",
      highKey: "high",
      lowKey: "low",
      closeKey: "close",
    },
  ],
  axes: {
    y: {
      type: "number",
      label: {
        formatter: ({ value }) => `$${Number(value).toFixed(0)}`,
      },
    },
  },
  flashOnUpdate: {
    enabled: true,
    fill: "#ffd6a5",
    flashDuration: 300,
    fadeOutDuration: 700,
  },
};

options.container = document.getElementById("myChart");

const chart = AgCharts.create(options);

function update() {
  data = applyLiveUpdate(data);
  options.data = data;

  chart.update(options);
}

function startUpdates() {
  if (isRunning) return;
  isRunning = true;
  updateButton();
  update();
  updateInterval = setInterval(update, 2000);
}

function stopUpdates() {
  if (!isRunning) return;
  isRunning = false;
  updateButton();
  if (updateInterval) {
    clearInterval(updateInterval);
    updateInterval = undefined;
  }
}

function updateButton() {
  const button = document.getElementById("toggleBtn");
  if (button) {
    button.textContent = isRunning ? "Stop Updates" : "Start Updates";
  }
}

function toggleUpdates() {
  if (isRunning) {
    stopUpdates();
  } else {
    startUpdates();
  }
}

function setColor(value: string) {
  options.flashOnUpdate!.fill = value;

  chart.update(options);
}

function setFlashDuration(value: string) {
  options.flashOnUpdate!.flashDuration = Number(value);

  chart.update(options);
}

function setFadeDuration(value: string) {
  options.flashOnUpdate!.fadeOutDuration = Number(value);

  chart.update(options);
}

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).toggleUpdates = toggleUpdates;
  (<any>window).setColor = setColor;
  (<any>window).setFlashDuration = setFlashDuration;
  (<any>window).setFadeDuration = setFadeDuration;
}
```

[Live example: Customisation](https://www.ag-grid.com/charts/typescript/flash-on-update/examples/flash-on-update-customisation)

```js
{
    flashOnUpdate: {
        enabled: true,
        fill: '#ffd6a5',
        flashDuration: 300,
        fadeOutDuration: 700,
    },
}
```

In this example:

- Use the 'Fill', 'Flash' and 'Fade' controls to adjust the flash appearance.
  - `fill` — the fill colour of the flash overlay.
  - `flashDuration` — how long (in milliseconds) the flash remains at full opacity before fading.
  - `fadeOutDuration` — how long (in milliseconds) the fade-out takes.
- Click 'Start Updates' to begin a simulated live price feed and observe the flash with the current settings.
- Click 'Stop Updates' to pause the feed.

## Animation

Flash on Update disables [Animation](https://www.ag-grid.com/charts/javascript/animation/) by default, as the two are rarely used together. If you do need both, explicitly set `animation: { enabled: true }`.

When both are enabled, the `flashDuration` and `fadeOutDuration` values are scaled to fit within the data update animation phases, so the actual timing may differ from the configured values. Their ratio still controls how the duration is split between the hold and fade stages.

## API Reference

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| enabled | boolean |  | Whether the flash effect is enabled. |
| item | 'chart' \| 'category' |  | What part of the chart to flash. |
| fill | CssColor |  | The fill colour of the flash effect. |
| fillOpacity | Opacity |  | The fill opacity of the flash effect. |
| flashDuration | DurationMs |  | The flash hold duration in milliseconds before fading begins. Actual timing may vary when animations are enabled. |
| fadeOutDuration | DurationMs |  | The fade-out duration in milliseconds. Actual timing may vary when animations are enabled. |
