# Draw Task (Gantt example)

> WestCoast Charts 1.1.5, release, public Core release, on npm. HTML: https://westcoast-charts.com/gallery/gantt/draw-task/ · Index for agents: https://westcoast-charts.com/llms.txt

drag.draw adds an empty row at the end of each group: drag across it to draw a new task (a dashed ghost shows the dates and length), or click "+ Add task" in the grid. The new item matches its neighbours' data shape and fires a cancelable taskCreate; undo removes it.

- Chart type: `gantt` (Gantt)
- Collection: Gantt · Gantt
- Raw configuration: https://westcoast-charts.com/gallery-src/gantt/draw-task.js
- Standalone example: https://westcoast-charts.com/embed/samples/wcc/gallery/premium/gantt/draw-task.html

## Setup

```js
import WestCoastCharts from 'west-coast-charts'
import types from 'west-coast-charts/types'
import premium from 'west-coast-charts/premium'

WestCoastCharts.use(types).use(premium)
const WestCoastChartsPremium = premium
WestCoastCharts.setLicenseKey(LICENCE_KEY) // paid production licence; localhost evaluation needs no key
```

## Options

```js
const options = {
  chart: {
    height: "auto",
    toolbar: {
      show: false
    },
    type: "gantt",
    events: {
      taskCreate: (e, ctx, o) => log(o.source + ': ' + (o.data.x || o.data.name) + ' ' + JSON.stringify(o.data.y || [o.data.start, o.data.end]))
    }
  },
  series: [
    {
      name: "Design",
      data: [
        {
          id: "a",
          x: "Workshop",
          y: [1792360800000, 1792533600000],
          progress: 100
        },
        {
          id: "b",
          x: "Wireframes",
          y: [1792533600000, 1793055600000],
          progress: 50,
          dependsOn: ["a"]
        }
      ]
    },
    {
      name: "Build",
      data: [
        {
          id: "c",
          x: "Prototype",
          y: [1792969200000, 1793574000000],
          progress: 10,
          dependsOn: ["b"]
        }
      ]
    }
  ],
  plotOptions: {
    gantt: {
      today: {
        date: "2026-10-22"
      },
      drag: {
        enabled: true,
        draw: true
      },
      range: {
        min: 1792188000000,
        max: 1794092400000
      }
    }
  },
  theme: {
    mode: "light",
    preset: "coastal"
  }
}

const chart = new WestCoastCharts(document.querySelector('#chart'), options)
await chart.render()
```

## Verify

- Text check (Library 1.1.5): load `west-coast-charts/agent/describe` and call `chart.describe({ format: "json" })` for the actual drawn state. The live reader is on this example’s HTML page.
- Command line (Public agent tools 0.2.3, tested with Library 1.1.5; available from the versioned GitHub release and npm, https://westcoast-charts.com/docs/cli/index.md): `wcc chart export gantt-draw-task.json --out gantt-draw-task.svg --with-table` (save the options above as JSON first)
