# Gantt Baselines
URL: https://pro.rv-grid.com/guides/gantt/concepts/baselines/
Source: src/content/docs/guides/gantt/concepts/baselines.mdx
Description: Capture a baseline snapshot of your schedule and overlay it beneath current task bars to visualise drift.
A **baseline** is a saved snapshot of task dates and progress at a specific point in time (e.g. when the project was approved).
The Gantt chart can overlay these baseline bars beneath the live bars, making schedule drift immediately visible.

---

## Adding a Baseline

Pass one or more `BaselineSnapshot` objects via `grid.ganttBaselines`:

```typescript
grid.ganttBaselines = [
  {
    id: 'baseline-approved',
    name: 'Approved Plan',
    capturedAt: '2026-04-01T08:00:00Z',
    tasks: [
      { taskId: 't1', startDate: '2026-04-06', endDate: '2026-04-22', durationDays: 13, progressPercent: 0 },
      { taskId: 't2', startDate: '2026-04-06', endDate: '2026-04-10', durationDays: 5,  progressPercent: 0 },
      { taskId: 't3', startDate: '2026-04-10', endDate: '2026-04-10', durationDays: 0,  progressPercent: 0 },
      { taskId: 't4', startDate: '2026-04-13', endDate: '2026-04-22', durationDays: 8,  progressPercent: 0 },
      { taskId: 't5', startDate: '2026-04-23', endDate: '2026-05-16', durationDays: 18, progressPercent: 0 },
      { taskId: 't6', startDate: '2026-04-23', endDate: '2026-05-09', durationDays: 13, progressPercent: 0 },
      { taskId: 't7', startDate: '2026-04-23', endDate: '2026-05-16', durationDays: 18, progressPercent: 0 },
      { taskId: 't8', startDate: '2026-05-16', endDate: '2026-05-16', durationDays: 0,  progressPercent: 0 },
    ],
  },
];
```

You can also capture a snapshot from the current scheduled state:

```typescript
const plugins = await grid.getPlugins();
const gantt = plugins.find((plugin) => plugin.constructor?.name === 'GanttPlugin');
const baseline = gantt?.captureBaseline?.({
  id: 'baseline-current',
  name: 'Current Approved Plan',
  capturedAt: '2026-04-15T08:00:00Z',
});

if (baseline) {
  grid.ganttBaselines = [
    ...(grid.ganttBaselines ?? []),
    baseline,
  ];
}
```

## Enabling the Overlay

Turn on baseline rendering through the `visuals` key in your project config:

```typescript
grid.gantt = {
  // …required fields
  visuals: {
    showBaseline: true,
    baselineId: 'baseline-approved', // optional — defaults to the latest snapshot
  },
};
```

When `showBaseline` is `true`, a translucent bar is drawn behind each live task bar showing its baseline position.

  Only tasks listed in `BaselineSnapshot.tasks` show a baseline bar. Tasks added after the snapshot was captured render without one.

## Multiple Baselines

You can store several snapshots and switch between them at runtime:

```typescript
// Initially show the approved plan
grid.gantt = { ...config, visuals: { showBaseline: true, baselineId: 'baseline-approved' } };

// Switch to a re-baseline after scope change
grid.gantt = { ...config, visuals: { showBaseline: true, baselineId: 'baseline-replan' } };
```

## Variance Columns

When a baseline is visible, each projected task row also exposes optional variance fields:

| Field | Description |
|---|---|
| `startVarianceDays` | Current scheduled start minus baseline start, in calendar days |
| `finishVarianceDays` | Current scheduled finish minus baseline finish, in calendar days |
| `durationVarianceDays` | Current scheduled duration minus baseline duration |
| `progressVariancePercent` | Current progress minus baseline progress, in percentage points |

Add the default columns when users need to inspect drift numerically:

```typescript
grid.columns = [
  createDefaultTaskTableColumn('name'),
  createDefaultTaskTableColumn('startVarianceDays'),
  createDefaultTaskTableColumn('finishVarianceDays'),
  createDefaultTaskTableColumn('durationVarianceDays'),
  createDefaultTaskTableColumn('progressVariancePercent'),
];
```

## BaselineSnapshot Fields

| Field | Type | Description |
|---|---|---|
| `id` | `BaselineId` | Unique identifier for this snapshot |
| `name` | `string` | Human-readable label (e.g. `"Q1 Approved Plan"`) |
| `capturedAt` | `ISODateTimeString` | When the snapshot was taken |
| `tasks` | `BaselineTaskSnapshot[]` | Per-task date and progress records |

### BaselineTaskSnapshot Fields

| Field | Type | Description |
|---|---|---|
| `taskId` | `TaskId` | References the live task |
| `startDate` | `ISODateString` | Baseline start date |
| `endDate` | `ISODateString` | Baseline end date |
| `durationDays` | `number` | Baseline duration in calendar days |
| `progressPercent` | `number` | Baseline progress (0–100) |
