demo D215
Gantt in Vue
A row label with a start and an end, coloured by phase
type: 'gantt', label, start, end
This draws a Gantt-style chart from a row label with a start and an end, coloured by phase. It lays activities out along a timeline so overlaps and sequence read at a glance, from ordinary rows with two dates.
This is the Vue 3 version. A createLatticeGrid component takes the configuration through v-bind, and reactive data flows straight into the grid, so it updates the way the rest of your Vue app does.
The configuration
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.min.css">
<style>
#chart { height: 320px; }
#grid { margin-top: 14px; }
#grid > div { height: 320px; }
</style>
<div id="app"></div>
<script type="module">
import * as Vue from 'https://esm.sh/vue@3/dist/vue.esm-browser.prod.js';
import { createGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.esm.min.js';
import createLatticeGrid from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/vue.esm.min.js';
import { createChart } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/charts.esm.min.js';
const LatticeGrid = createLatticeGrid({ vue: Vue, createGrid });
Vue.createApp({
components: { LatticeGrid },
data() {
return {
config: {
rowKey: 'id',
columns: [
{ field: 'task', title: 'Task', layout: { width: 160 } },
{ field: 'phase', title: 'Phase', filter: { type: 'set' } },
{ field: 'start', title: 'Start', type: 'date' },
{ field: 'end', title: 'End', type: 'date' },
],
rows, // e.g. [{ id: 1, task: 'Discovery', phase: 'Plan', start: '2026-01-06', end: '2026-01-14' }, …]
},
};
},
mounted() {
// The component exposes the live grid via a template ref, which the chart draws from.
const grid = this.$refs.grid.grid();
// Gantt reads a row label and a start and end date; series colours the bars.
createChart({ grid, container: '#chart', type: 'gantt',
label: 'task', start: 'start', end: 'end', series: 'phase', legend: true });
},
template: `
<div id="chart"></div>
<div id="grid"><lattice-grid ref="grid" v-bind="config" /></div>
`,
}).mount('#app');
</script>