Baselines (Planned vs Actual)

A baseline is the original planned schedule for a task. When baseline.enabled is true, ApexGantt renders a thin secondary bar directly below each task bar that has a baseline field. The gap between the actual bar and the baseline bar shows schedule variance at a glance.

Adding baselines to tasks

Attach a baseline object to any TaskInput. It requires two fields: start and end (the originally planned dates):

const tasks = [
  {
    id: 'task-1',
    name: 'Research Phase',
    startTime: '2024-03-01',
    endTime: '2024-03-20',     // actual end (slipped)
    progress: 100,
    baseline: {
      start: '2024-03-01',    // planned start
      end: '2024-03-10',      // planned end
    },
  },
  {
    id: 'task-2',
    name: 'Design',
    startTime: '2024-03-21',
    endTime: '2024-04-05',
    progress: 60,
    baseline: {
      start: '2024-03-11',
      end: '2024-03-31',
    },
  },
]

Enabling baseline rendering

Enable it once at the chart level with baseline.enabled: true:

const gantt = new ApexGantt(document.getElementById('chart'), {
  inputDateFormat: 'YYYY-MM-DD', // task and baseline dates share this format
  series: tasks,
  baseline: {
    enabled: true,
  },
})

Tasks that do not have a baseline field show no secondary bar. Tasks that do show a thin striped bar below the main bar. When baselines are enabled and you have not set rowHeight, rows grow by 12px (to 52px) to make room for the second bar.

Since 3.20.0 the parsing option can map baseline from your own field names too.

BaselineOptions

OptionTypeDefaultDescription
enabledbooleanfalseWhether to render baseline bars
colorstringThe bar's progress shadePrimary bar color (fills solid when striped: false; paints the stripes when striped: true). When omitted, each baseline takes the darker progress tone of its own task bar, so it reads as the planned twin of that bar
stripedbooleantrueFill with diagonal stripes instead of a flat color
stripeColorstring'#FFFFFF'Color of the gaps between stripes
stripeWidthnumber3Width of each stripe band in pixels
stripeAnglenumber45Stripe angle in degrees

Customizing the baseline bar

const gantt = new ApexGantt(el, {
  series: tasks,
  baseline: {
    enabled: true,
    color: '#6366F1',        // indigo stripes
    striped: true,
    stripeColor: '#EEF2FF',  // light indigo gaps
    stripeWidth: 4,
    stripeAngle: 45,
  },
})

Solid baseline bar (no stripes)

baseline: {
  enabled: true,
  striped: false,
  color: '#94A3B8',   // flat slate color
},

Baseline tooltip

When a user hovers the baseline bar, a tooltip appears showing the planned start and end dates. The label strings come from locale.messages:

  • baselineLabel defaults to 'Baseline:'
  • startLabel defaults to 'Start:'
  • endLabel defaults to 'End:'

Override them via locale.messages for localization:

const gantt = new ApexGantt(el, {
  series: tasks,
  baseline: { enabled: true },
  locale: {
    messages: {
      baselineLabel: 'Plan:',
      startLabel: 'From:',
      endLabel: 'To:',
    },
  },
})

Updating baselines at runtime

Call updateTask() to set or revise a task's baseline after the initial render, for example when a project is re-baselined after a scope change:

gantt.updateTask('task-1', {
  baseline: {
    start: '2024-03-01',
    end: '2024-03-15',   // revised plan
  },
})

Call update({ series: newTasks }) to replace the full dataset when all baselines change (since 3.20.0 this also clears the undo history).

Showing variance in the task list

Add the baselineStart, baselineEnd and baselineVariance columns to columnConfig to show the plan next to the actual dates. baselineVariance is the actual end minus the baseline end, for example +10 d for a task finishing ten days late. Since 3.20.0 it counts working days (wd) when a calendar is set; before 3.20.0 it always counted calendar days.

columnConfig: [
  { key: 'name', title: 'Task' },
  { key: 'endTime', title: 'End' },
  { key: 'baselineEnd', title: 'Planned end' },
  { key: 'baselineVariance', title: 'Variance' },
],

React example

import { ApexGanttChart } from 'react-apexgantt'
import type { GanttUserOptions, TaskInput } from 'react-apexgantt'

const tasks: TaskInput[] = [
  {
    id: 'task-1',
    name: 'Research',
    startTime: '2024-03-01',
    endTime: '2024-03-20',
    progress: 100,
    baseline: { start: '2024-03-01', end: '2024-03-10' },
  },
  {
    id: 'task-2',
    name: 'Design',
    startTime: '2024-03-21',
    endTime: '2024-04-05',
    progress: 60,
    baseline: { start: '2024-03-11', end: '2024-03-31' },
  },
  {
    id: 'task-3',
    name: 'Development',
    startTime: '2024-04-06',
    endTime: '2024-05-10',
    progress: 20,
    baseline: { start: '2024-04-01', end: '2024-04-30' },
  },
]

const options: Omit<GanttUserOptions, 'series'> = {
  inputDateFormat: 'YYYY-MM-DD',
  baseline: {
    enabled: true,
    color: '#6366F1',
    striped: true,
    stripeColor: '#EEF2FF',
  },
}

export default function BaselineGantt() {
  return (
    <ApexGanttChart
      tasks={tasks}
      options={options}
      pixelsPerDay={25.7}
      height="500px"
    />
  )
}

Vue example

<template>
  <ApexGanttChart :tasks="tasks" :options="ganttOptions" :pixels-per-day="25.7" height="500px" />
</template>

<script setup lang="ts">
import type { GanttUserOptions, TaskInput } from 'vue-apexgantt'

const tasks: TaskInput[] = [
  {
    id: 'task-1',
    name: 'Research',
    startTime: '2024-03-01',
    endTime: '2024-03-20',
    progress: 100,
    baseline: { start: '2024-03-01', end: '2024-03-10' },
  },
  {
    id: 'task-2',
    name: 'Design',
    startTime: '2024-03-21',
    endTime: '2024-04-05',
    progress: 60,
    baseline: { start: '2024-03-11', end: '2024-03-31' },
  },
]

const ganttOptions: Partial<GanttUserOptions> = {
  inputDateFormat: 'YYYY-MM-DD',
  baseline: {
    enabled: true,
    color: '#6366F1',
    striped: true,
  },
}
</script>