본문으로 건너뛰기Skip to content
예제 첫화면Examples home

그리드 없이 간트 차트만 쓰기The Gantt chart without a grid

표 없이 간트 차트 하나만 페이지에 넣어요. 호스트 요소와 setData, 이벤트만 있으면 돼요.Put a single Gantt chart on a page with no grid: one host element, setData and events.

입문Beginner
직접 써 보기Live preview그리드 없이 간트 차트만 쓰기The Gantt chart without a grid

코드Code

탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.

빌드 도구(Vite 등)를 쓰는 프로젝트용 모듈 파일이에요. 설치 없이 바로 돌려 보려면 HTML 탭이나 직접 해보기를 쓰세요.

이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i maxgrid @maxgrid/gantt로 설치하세요.

버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.

index.html
<div id="app">
  <div id="grid" style="height: 460px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { setup } from './example';
setup(document.getElementById('grid'), console.log);
example.js
import { createGantt } from '@maxgrid/gantt';
// 그리드 없이 간트 차트만 써요. 맥스그리드 번들이나 표는 필요 없고, 호스트 요소 하나와 데이터만 있으면 돼요.
// 날짜 계산은 하지 않고 받은 값을 그대로 그려요. 요약 작업(1, 2, 5)의 날짜와 진행률은 호스트가 합산해 넣어요.
// 작업은 평평한 목록이고 트리는 parentId로 만들어요(sortNo는 같은 부모 안의 순서).
const data = {
  tasks: [
    {
      id: '1',
      parentId: null,
      sortNo: 1,
      name: '웹사이트 개편',
      status: 'IN_PROGRESS',
      plannedStart: '2026-11-02',
      plannedEnd: '2027-01-29',
      progressPct: 40,
      isMilestone: false,
      hasChildren: true,
      calendarId: null,
      version: 1,
    },
    {
      id: '2',
      parentId: '1',
      sortNo: 1,
      name: '디자인',
      status: 'DONE',
      plannedStart: '2026-11-02',
      plannedEnd: '2026-11-20',
      progressPct: 100,
      isMilestone: false,
      hasChildren: true,
      calendarId: null,
      version: 1,
    },
    {
      id: '3',
      parentId: '2',
      sortNo: 1,
      name: '와이어프레임',
      status: 'DONE',
      plannedStart: '2026-11-02',
      plannedEnd: '2026-11-10',
      progressPct: 100,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '4',
      parentId: '2',
      sortNo: 2,
      name: '화면 디자인',
      status: 'DONE',
      plannedStart: '2026-11-11',
      plannedEnd: '2026-11-20',
      progressPct: 100,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '5',
      parentId: '1',
      sortNo: 2,
      name: '개발',
      status: 'IN_PROGRESS',
      plannedStart: '2026-11-23',
      plannedEnd: '2027-01-15',
      progressPct: 30,
      isMilestone: false,
      hasChildren: true,
      calendarId: null,
      version: 1,
    },
    {
      id: '6',
      parentId: '5',
      sortNo: 1,
      name: '프런트엔드',
      status: 'IN_PROGRESS',
      plannedStart: '2026-11-23',
      plannedEnd: '2026-12-18',
      progressPct: 60,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '7',
      parentId: '5',
      sortNo: 2,
      name: '백엔드',
      status: 'IN_PROGRESS',
      plannedStart: '2026-11-30',
      plannedEnd: '2027-01-08',
      progressPct: 20,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '8',
      parentId: '5',
      sortNo: 3,
      name: '콘텐츠 이전',
      status: 'ON_HOLD',
      plannedStart: '2026-12-07',
      plannedEnd: '2026-12-24',
      progressPct: 0,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '9',
      parentId: '5',
      sortNo: 4,
      name: '통합 시험',
      status: 'TODO',
      plannedStart: '2027-01-04',
      plannedEnd: '2027-01-15',
      progressPct: 0,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '10',
      parentId: '1',
      sortNo: 3,
      name: '출시',
      status: 'TODO',
      plannedStart: '2027-01-29',
      plannedEnd: '2027-01-29',
      progressPct: 0,
      isMilestone: true,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
  ],
  dependencies: [
    { id: 'd1', predecessorId: '3', successorId: '4', depType: 'FS', lagDays: 0 },
    { id: 'd2', predecessorId: '4', successorId: '6', depType: 'FS', lagDays: 0 },
    { id: 'd3', predecessorId: '6', successorId: '9', depType: 'FS', lagDays: 0 },
    { id: 'd4', predecessorId: '9', successorId: '10', depType: 'FS', lagDays: 0 },
  ],
  calendars: [{ id: 'c1', name: '표준', workDays: 31, isDefault: true, exceptions: [] }],
};
export function setup(host, log) {
  const gantt = createGantt(host, {
    ariaLabel: '프로젝트 일정',
    locale: 'ko',
    rowHeight: 32,
    today: '2026-11-26',
  });
  gantt.setData(data);
  // 사용자가 하는 일은 이벤트로 받아요. 읽기 전용 차트가 보내는 이벤트는 네 가지예요.
  const offs = [
    gantt.on('row-select', (e) => log({ ko: `행 선택: ${e.taskId ?? '없음'}`, en: `Row selected: ${e.taskId ?? 'none'}` })),
    gantt.on('task-open', (e) => log({
      ko: `작업 열기(더블클릭): ${e.taskId}`,
      en: `Task opened (double-click): ${e.taskId}`,
    })),
    gantt.on('toggle-collapse', (e) => log({
      ko: `${e.taskId}번 ${e.collapsed ? '접힘' : '펼침'}`,
      en: `Task ${e.taskId} ${e.collapsed ? 'collapsed' : 'expanded'}`,
    })),
    gantt.on('viewport-change', (e) => log({
      ko: `보이는 구간: ${e.zoom} 단계, ${e.from} ~ ${e.to}`,
      en: `Viewport: ${e.zoom} zoom, ${e.from} to ${e.to}`,
    })),
  ];
  log({
    ko: `작업 ${data.tasks.length}개, 의존 ${data.dependencies.length}개를 불러왔어요`,
    en: `Loaded ${data.tasks.length} tasks and ${data.dependencies.length} dependencies`,
  });
  return () => {
    offs.forEach((off) => off());
    gantt.destroy();
  };
}

Module files for a project with a bundler such as Vite. To run it with no setup, use the HTML tab or Try it.

This example needs an extra package. To run it locally, install with npm i maxgrid @maxgrid/gantt.

When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.

index.html
<div id="app">
  <div id="grid" style="height: 460px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { setup } from './example';
setup(document.getElementById('grid'), console.log);
example.js
import { createGantt } from '@maxgrid/gantt';
// The Gantt chart on its own: no MaxGrid bundle and no grid, just one host element and the data.
// The chart does not calculate dates; it draws what it gets. The host sums the dates and progress of summary tasks (1, 2, 5).
// Tasks are a flat list; the tree comes from parentId (sortNo is the order inside a parent).
const data = {
  tasks: [
    {
      id: '1',
      parentId: null,
      sortNo: 1,
      name: 'Website relaunch',
      status: 'IN_PROGRESS',
      plannedStart: '2026-11-02',
      plannedEnd: '2027-01-29',
      progressPct: 40,
      isMilestone: false,
      hasChildren: true,
      calendarId: null,
      version: 1,
    },
    {
      id: '2',
      parentId: '1',
      sortNo: 1,
      name: 'Design',
      status: 'DONE',
      plannedStart: '2026-11-02',
      plannedEnd: '2026-11-20',
      progressPct: 100,
      isMilestone: false,
      hasChildren: true,
      calendarId: null,
      version: 1,
    },
    {
      id: '3',
      parentId: '2',
      sortNo: 1,
      name: 'Wireframes',
      status: 'DONE',
      plannedStart: '2026-11-02',
      plannedEnd: '2026-11-10',
      progressPct: 100,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '4',
      parentId: '2',
      sortNo: 2,
      name: 'Visual design',
      status: 'DONE',
      plannedStart: '2026-11-11',
      plannedEnd: '2026-11-20',
      progressPct: 100,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '5',
      parentId: '1',
      sortNo: 2,
      name: 'Build',
      status: 'IN_PROGRESS',
      plannedStart: '2026-11-23',
      plannedEnd: '2027-01-15',
      progressPct: 30,
      isMilestone: false,
      hasChildren: true,
      calendarId: null,
      version: 1,
    },
    {
      id: '6',
      parentId: '5',
      sortNo: 1,
      name: 'Frontend',
      status: 'IN_PROGRESS',
      plannedStart: '2026-11-23',
      plannedEnd: '2026-12-18',
      progressPct: 60,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '7',
      parentId: '5',
      sortNo: 2,
      name: 'Backend',
      status: 'IN_PROGRESS',
      plannedStart: '2026-11-30',
      plannedEnd: '2027-01-08',
      progressPct: 20,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '8',
      parentId: '5',
      sortNo: 3,
      name: 'Content migration',
      status: 'ON_HOLD',
      plannedStart: '2026-12-07',
      plannedEnd: '2026-12-24',
      progressPct: 0,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '9',
      parentId: '5',
      sortNo: 4,
      name: 'Integration test',
      status: 'TODO',
      plannedStart: '2027-01-04',
      plannedEnd: '2027-01-15',
      progressPct: 0,
      isMilestone: false,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
    {
      id: '10',
      parentId: '1',
      sortNo: 3,
      name: 'Launch',
      status: 'TODO',
      plannedStart: '2027-01-29',
      plannedEnd: '2027-01-29',
      progressPct: 0,
      isMilestone: true,
      hasChildren: false,
      calendarId: null,
      version: 1,
    },
  ],
  dependencies: [
    { id: 'd1', predecessorId: '3', successorId: '4', depType: 'FS', lagDays: 0 },
    { id: 'd2', predecessorId: '4', successorId: '6', depType: 'FS', lagDays: 0 },
    { id: 'd3', predecessorId: '6', successorId: '9', depType: 'FS', lagDays: 0 },
    { id: 'd4', predecessorId: '9', successorId: '10', depType: 'FS', lagDays: 0 },
  ],
  calendars: [{ id: 'c1', name: 'Standard', workDays: 31, isDefault: true, exceptions: [] }],
};
export function setup(host, log) {
  const gantt = createGantt(host, {
    ariaLabel: 'Project plan',
    locale: 'en',
    rowHeight: 32,
    today: '2026-11-26',
  });
  gantt.setData(data);
  // What the user does arrives as events. A read-only chart sends four of them.
  const offs = [
    gantt.on('row-select', (e) => log(`Row selected: ${e.taskId ?? 'none'}`)),
    gantt.on('task-open', (e) => log(`Task opened (double-click): ${e.taskId}`)),
    gantt.on('toggle-collapse', (e) => log(`Task ${e.taskId} ${e.collapsed ? 'collapsed' : 'expanded'}`)),
    gantt.on('viewport-change', (e) => log(`Viewport: ${e.zoom} zoom, ${e.from} to ${e.to}`)),
  ];
  log(`Loaded ${data.tasks.length} tasks and ${data.dependencies.length} dependencies`);
  return () => {
    offs.forEach((off) => off());
    gantt.destroy();
  };
}