작업 5,000개를 가상 스크롤로 그리기Draw 5,000 tasks with virtual scrolling
시험용 작업 1,000개 또는 5,000개를 불러오고 걸린 시간을 기록에서 봐요.Load 1,000 or 5,000 fixture tasks and read the load time in the log.
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i maxgrid @maxgrid/gantt @maxgrid/gantt-core로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div class="toolbar">
<select aria-label="작업 수" id="count">
<option value="1000">1,000개</option>
<option value="5000" selected>5,000개</option>
</select>
</div>
<div id="grid" style="height: 480px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('count').addEventListener('change', (event) => actions.count(api, event.target.value));import { createGantt, createSplitView } from '@maxgrid/gantt';
import { makeFixture } from '@maxgrid/gantt-core';
export const options = {
columns: [
{ id: 'wbs', title: 'WBS', width: 140 },
{ id: 'name', title: '작업', width: 300 },
{ id: 'assignee', title: '담당자', width: 110 },
{ id: 'start', title: '시작', width: 100 },
{ id: 'end', title: '종료', width: 100 },
{
id: 'progress',
title: '진행률(%)',
kind: 'number',
width: 90,
align: 'center',
cellRenderer: 'progressRing',
},
],
rows: [],
rowKey: 'id',
rowHeight: 40,
headerHeight: 48,
verticalScroll: 'external',
selection: 'single',
tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// 간트 작업을 표 행으로 바꿔요.
function toRow(t) {
return {
id: t.id,
parentId: t.parentId,
wbs: t.wbsCode ?? '',
name: t.name,
assignee: t.assigneeName ?? '',
start: t.plannedStart ?? '',
end: t.plannedEnd ?? '',
progress: t.progressPct,
};
}
// 표 옆에 간트 차트를 붙여요: 표 요소를 왼쪽 칸으로 옮기고 createSplitView로 묶어요.
function mountGantt(api, ganttOptions = {}) {
const gridEl = api.getGridElement();
// 깊이 18까지 이름이 읽히도록 들여쓰기 폭을 줄여요(기본 16px는 깊이 18에서 288px라 이름 칸을 다 채워요).
gridEl.style.setProperty('--mxg-indent', '6px');
const host = gridEl.parentElement;
const box = document.createElement('div');
const left = document.createElement('div');
const right = document.createElement('div');
box.style.cssText = 'position: relative; width: 100%; height: 100%;';
box.append(left, right);
host.append(box);
left.append(gridEl);
const split = createSplitView({
left,
right,
container: box,
initial: 0.45,
min: box.clientWidth < 600 ? 110 : 240,
});
// 좁은 컨테이너(600px 미만)에서는 앞의 열만 남겨 차트 자리를 확보해요. 넓어지면 열이 돌아와요.
const fitColumns = () => {
const narrow = box.clientWidth < 600;
for (const id of ['assignee', 'start', 'end', 'progress'])
api.setColumnVisible(id, !narrow);
api.resizeColumn('wbs', narrow ? 58 : 70);
};
fitColumns();
const fitObserver = new ResizeObserver(fitColumns);
fitObserver.observe(box);
const gantt = createGantt(right, {
rowHeight: 40,
barHeight: 24,
locale: 'ko',
verticalScroll: 'external',
...ganttOptions,
});
return {
gantt,
box,
right,
// 연결을 풀고 표를 원래 자리로 돌려놔요.
destroy() {
gantt.destroy();
fitObserver.disconnect();
split.destroy();
host.append(gridEl);
box.remove();
},
};
}
let view = null;
let say = () => { };
// 시험용 작업을 만들어 표와 차트에 넣고 걸린 시간을 적어요. 작업 id가 같아서 두 쪽이 행 키로 짝지어져요.
function load(api, count) {
if (!view)
return;
const t0 = performance.now();
const data = makeFixture({
tasks: count,
dependencies: Math.round(count * 1.2),
seed: 1,
startDate: '2026-10-05',
});
const t1 = performance.now();
api.setRows([...data.tasks].sort((a, b) => a.sortNo - b.sortNo).map(toRow));
const t2 = performance.now();
view.gantt.setData(data);
const t3 = performance.now();
say({
ko: `작업 ${count.toLocaleString('ko-KR')}개: 데이터 만들기 ${Math.round(t1 - t0)}ms · 표 ${Math.round(t2 - t1)}ms · gantt.setData ${Math.round(t3 - t2)}ms`,
en: `${count.toLocaleString('en-US')} tasks: build ${Math.round(t1 - t0)} ms · grid ${Math.round(t2 - t1)} ms · gantt.setData ${Math.round(t3 - t2)} ms`,
});
}
export function setup(api, log) {
say = log;
view = mountGantt(api);
load(api, 5000);
const unlink = view.gantt.attachGrid(api);
return () => {
unlink();
view?.destroy();
view = null;
};
}
export const actions = {
count: (api, value) => load(api, Number(value) || 5000),
}; 이 HTML은 추가 번들(위 script 태그)도 함께 불러오고 전역 변수로 써요. 별도 설치는 필요 없어요.
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>작업 5,000개를 가상 스크롤로 그리기</title>
</head>
<body>
<div class="toolbar">
<select aria-label="작업 수" id="count">
<option value="1000">1,000개</option>
<option value="5000" selected>5,000개</option>
</select>
</div>
<div id="grid" style="height: 480px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<link rel="stylesheet" href="https://cdn.maxmine.com/maxgrid/latest/maxgrid.gantt.css" />
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.gantt.min.js"></script>
<script>
const { createGantt, createSplitView } = MaxGridGantt;
const { makeFixture } = MaxGridGantt;
const options = {
columns: [
{ id: 'wbs', title: 'WBS', width: 140 },
{ id: 'name', title: '작업', width: 300 },
{ id: 'assignee', title: '담당자', width: 110 },
{ id: 'start', title: '시작', width: 100 },
{ id: 'end', title: '종료', width: 100 },
{
id: 'progress',
title: '진행률(%)',
kind: 'number',
width: 90,
align: 'center',
cellRenderer: 'progressRing',
},
],
rows: [],
rowKey: 'id',
rowHeight: 40,
headerHeight: 48,
verticalScroll: 'external',
selection: 'single',
tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// 간트 작업을 표 행으로 바꿔요.
function toRow(t) {
return {
id: t.id,
parentId: t.parentId,
wbs: t.wbsCode ?? '',
name: t.name,
assignee: t.assigneeName ?? '',
start: t.plannedStart ?? '',
end: t.plannedEnd ?? '',
progress: t.progressPct,
};
}
// 표 옆에 간트 차트를 붙여요: 표 요소를 왼쪽 칸으로 옮기고 createSplitView로 묶어요.
function mountGantt(api, ganttOptions = {}) {
const gridEl = api.getGridElement();
// 깊이 18까지 이름이 읽히도록 들여쓰기 폭을 줄여요(기본 16px는 깊이 18에서 288px라 이름 칸을 다 채워요).
gridEl.style.setProperty('--mxg-indent', '6px');
const host = gridEl.parentElement;
const box = document.createElement('div');
const left = document.createElement('div');
const right = document.createElement('div');
box.style.cssText = 'position: relative; width: 100%; height: 100%;';
box.append(left, right);
host.append(box);
left.append(gridEl);
const split = createSplitView({
left,
right,
container: box,
initial: 0.45,
min: box.clientWidth < 600 ? 110 : 240,
});
// 좁은 컨테이너(600px 미만)에서는 앞의 열만 남겨 차트 자리를 확보해요. 넓어지면 열이 돌아와요.
const fitColumns = () => {
const narrow = box.clientWidth < 600;
for (const id of ['assignee', 'start', 'end', 'progress'])
api.setColumnVisible(id, !narrow);
api.resizeColumn('wbs', narrow ? 58 : 70);
};
fitColumns();
const fitObserver = new ResizeObserver(fitColumns);
fitObserver.observe(box);
const gantt = createGantt(right, {
rowHeight: 40,
barHeight: 24,
locale: 'ko',
verticalScroll: 'external',
...ganttOptions,
});
return {
gantt,
box,
right,
// 연결을 풀고 표를 원래 자리로 돌려놔요.
destroy() {
gantt.destroy();
fitObserver.disconnect();
split.destroy();
host.append(gridEl);
box.remove();
},
};
}
let view = null;
let say = () => { };
// 시험용 작업을 만들어 표와 차트에 넣고 걸린 시간을 적어요. 작업 id가 같아서 두 쪽이 행 키로 짝지어져요.
function load(api, count) {
if (!view)
return;
const t0 = performance.now();
const data = makeFixture({
tasks: count,
dependencies: Math.round(count * 1.2),
seed: 1,
startDate: '2026-10-05',
});
const t1 = performance.now();
api.setRows([...data.tasks].sort((a, b) => a.sortNo - b.sortNo).map(toRow));
const t2 = performance.now();
view.gantt.setData(data);
const t3 = performance.now();
say({
ko: `작업 ${count.toLocaleString('ko-KR')}개: 데이터 만들기 ${Math.round(t1 - t0)}ms · 표 ${Math.round(t2 - t1)}ms · gantt.setData ${Math.round(t3 - t2)}ms`,
en: `${count.toLocaleString('en-US')} tasks: build ${Math.round(t1 - t0)} ms · grid ${Math.round(t2 - t1)} ms · gantt.setData ${Math.round(t3 - t2)} ms`,
});
}
function setup(api, log) {
say = log;
view = mountGantt(api);
load(api, 5000);
const unlink = view.gantt.attachGrid(api);
return () => {
unlink();
view?.destroy();
view = null;
};
}
const actions = {
count: (api, value) => load(api, Number(value) || 5000),
};
options.ariaLabel = "작업 5,000개를 가상 스크롤로 그리기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('count').addEventListener('change', (event) => actions.count(api, event.target.value));
</script>
</body>
</html> 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/react @maxgrid/gantt @maxgrid/gantt-core로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<select
aria-label="작업 수"
disabled={!api}
onChange={(event) => api && actions.count(api, event.target.value)}
>
<option value="1000">1,000개</option>
<option value="5000">5,000개</option>
</select>
</div>
<Grid style={{ height: 480 }} ref={gridRef} options={options} />
</>
);
}import { createGantt, createSplitView } from '@maxgrid/gantt';
import { makeFixture } from '@maxgrid/gantt-core';
import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: string;
parentId: string | null;
wbs: string;
name: string;
assignee: string;
start: string;
end: string;
progress: number;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'wbs', title: 'WBS', width: 140 },
{ id: 'name', title: '작업', width: 300 },
{ id: 'assignee', title: '담당자', width: 110 },
{ id: 'start', title: '시작', width: 100 },
{ id: 'end', title: '종료', width: 100 },
{
id: 'progress',
title: '진행률(%)',
kind: 'number',
width: 90,
align: 'center',
cellRenderer: 'progressRing',
},
],
rows: [],
rowKey: 'id',
rowHeight: 40,
headerHeight: 48,
verticalScroll: 'external',
selection: 'single',
tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// 간트 작업을 표 행으로 바꿔요.
function toRow(t: {
id: string;
parentId: string | null;
wbsCode?: string;
name: string;
assigneeName?: string;
plannedStart: string | null;
plannedEnd: string | null;
progressPct: number;
}): Row {
return {
id: t.id,
parentId: t.parentId,
wbs: t.wbsCode ?? '',
name: t.name,
assignee: t.assigneeName ?? '',
start: t.plannedStart ?? '',
end: t.plannedEnd ?? '',
progress: t.progressPct,
};
}
// 표 옆에 간트 차트를 붙여요: 표 요소를 왼쪽 칸으로 옮기고 createSplitView로 묶어요.
function mountGantt(api: GridApi<Row>, ganttOptions: Parameters<typeof createGantt>[1] = {}) {
const gridEl = api.getGridElement();
// 깊이 18까지 이름이 읽히도록 들여쓰기 폭을 줄여요(기본 16px는 깊이 18에서 288px라 이름 칸을 다 채워요).
gridEl.style.setProperty('--mxg-indent', '6px');
const host = gridEl.parentElement as HTMLElement;
const box = document.createElement('div');
const left = document.createElement('div');
const right = document.createElement('div');
box.style.cssText = 'position: relative; width: 100%; height: 100%;';
box.append(left, right);
host.append(box);
left.append(gridEl);
const split = createSplitView({
left,
right,
container: box,
initial: 0.45,
min: box.clientWidth < 600 ? 110 : 240,
});
// 좁은 컨테이너(600px 미만)에서는 앞의 열만 남겨 차트 자리를 확보해요. 넓어지면 열이 돌아와요.
const fitColumns = (): void => {
const narrow = box.clientWidth < 600;
for (const id of ['assignee', 'start', 'end', 'progress']) api.setColumnVisible(id, !narrow);
api.resizeColumn('wbs', narrow ? 58 : 70);
};
fitColumns();
const fitObserver = new ResizeObserver(fitColumns);
fitObserver.observe(box);
const gantt = createGantt(right, {
rowHeight: 40,
barHeight: 24,
locale: 'ko',
verticalScroll: 'external',
...ganttOptions,
});
return {
gantt,
box,
right,
// 연결을 풀고 표를 원래 자리로 돌려놔요.
destroy() {
gantt.destroy();
fitObserver.disconnect();
split.destroy();
host.append(gridEl);
box.remove();
},
};
}
let view: ReturnType<typeof mountGantt> | null = null;
let say: (message: LogText) => void = () => {};
// 시험용 작업을 만들어 표와 차트에 넣고 걸린 시간을 적어요. 작업 id가 같아서 두 쪽이 행 키로 짝지어져요.
function load(api: GridApi<Row>, count: number) {
if (!view) return;
const t0 = performance.now();
const data = makeFixture({
tasks: count,
dependencies: Math.round(count * 1.2),
seed: 1,
startDate: '2026-10-05',
});
const t1 = performance.now();
api.setRows([...data.tasks].sort((a, b) => a.sortNo - b.sortNo).map(toRow));
const t2 = performance.now();
view.gantt.setData(data);
const t3 = performance.now();
say({
ko: `작업 ${count.toLocaleString('ko-KR')}개: 데이터 만들기 ${Math.round(t1 - t0)}ms · 표 ${Math.round(t2 - t1)}ms · gantt.setData ${Math.round(t3 - t2)}ms`,
en: `${count.toLocaleString('en-US')} tasks: build ${Math.round(t1 - t0)} ms · grid ${Math.round(t2 - t1)} ms · gantt.setData ${Math.round(t3 - t2)} ms`,
});
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
view = mountGantt(api);
load(api, 5000);
const unlink = view.gantt.attachGrid(api);
return () => {
unlink();
view?.destroy();
view = null;
};
}
export const actions = {
count: (api: GridApi<Row>, value?: string) => load(api, Number(value) || 5000),
}; 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/vue @maxgrid/gantt @maxgrid/gantt-core로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<select
aria-label="작업 수"
:disabled="!api"
@change="api && actions.count(api, ($event.target as HTMLSelectElement).value)"
>
<option value="1000">1,000개</option>
<option value="5000" selected>5,000개</option>
</select>
</div>
<Grid style="height: 480px" :options="options" @ready="onReady" />
</template>import { createGantt, createSplitView } from '@maxgrid/gantt';
import { makeFixture } from '@maxgrid/gantt-core';
import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: string;
parentId: string | null;
wbs: string;
name: string;
assignee: string;
start: string;
end: string;
progress: number;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'wbs', title: 'WBS', width: 140 },
{ id: 'name', title: '작업', width: 300 },
{ id: 'assignee', title: '담당자', width: 110 },
{ id: 'start', title: '시작', width: 100 },
{ id: 'end', title: '종료', width: 100 },
{
id: 'progress',
title: '진행률(%)',
kind: 'number',
width: 90,
align: 'center',
cellRenderer: 'progressRing',
},
],
rows: [],
rowKey: 'id',
rowHeight: 40,
headerHeight: 48,
verticalScroll: 'external',
selection: 'single',
tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// 간트 작업을 표 행으로 바꿔요.
function toRow(t: {
id: string;
parentId: string | null;
wbsCode?: string;
name: string;
assigneeName?: string;
plannedStart: string | null;
plannedEnd: string | null;
progressPct: number;
}): Row {
return {
id: t.id,
parentId: t.parentId,
wbs: t.wbsCode ?? '',
name: t.name,
assignee: t.assigneeName ?? '',
start: t.plannedStart ?? '',
end: t.plannedEnd ?? '',
progress: t.progressPct,
};
}
// 표 옆에 간트 차트를 붙여요: 표 요소를 왼쪽 칸으로 옮기고 createSplitView로 묶어요.
function mountGantt(api: GridApi<Row>, ganttOptions: Parameters<typeof createGantt>[1] = {}) {
const gridEl = api.getGridElement();
// 깊이 18까지 이름이 읽히도록 들여쓰기 폭을 줄여요(기본 16px는 깊이 18에서 288px라 이름 칸을 다 채워요).
gridEl.style.setProperty('--mxg-indent', '6px');
const host = gridEl.parentElement as HTMLElement;
const box = document.createElement('div');
const left = document.createElement('div');
const right = document.createElement('div');
box.style.cssText = 'position: relative; width: 100%; height: 100%;';
box.append(left, right);
host.append(box);
left.append(gridEl);
const split = createSplitView({
left,
right,
container: box,
initial: 0.45,
min: box.clientWidth < 600 ? 110 : 240,
});
// 좁은 컨테이너(600px 미만)에서는 앞의 열만 남겨 차트 자리를 확보해요. 넓어지면 열이 돌아와요.
const fitColumns = (): void => {
const narrow = box.clientWidth < 600;
for (const id of ['assignee', 'start', 'end', 'progress']) api.setColumnVisible(id, !narrow);
api.resizeColumn('wbs', narrow ? 58 : 70);
};
fitColumns();
const fitObserver = new ResizeObserver(fitColumns);
fitObserver.observe(box);
const gantt = createGantt(right, {
rowHeight: 40,
barHeight: 24,
locale: 'ko',
verticalScroll: 'external',
...ganttOptions,
});
return {
gantt,
box,
right,
// 연결을 풀고 표를 원래 자리로 돌려놔요.
destroy() {
gantt.destroy();
fitObserver.disconnect();
split.destroy();
host.append(gridEl);
box.remove();
},
};
}
let view: ReturnType<typeof mountGantt> | null = null;
let say: (message: LogText) => void = () => {};
// 시험용 작업을 만들어 표와 차트에 넣고 걸린 시간을 적어요. 작업 id가 같아서 두 쪽이 행 키로 짝지어져요.
function load(api: GridApi<Row>, count: number) {
if (!view) return;
const t0 = performance.now();
const data = makeFixture({
tasks: count,
dependencies: Math.round(count * 1.2),
seed: 1,
startDate: '2026-10-05',
});
const t1 = performance.now();
api.setRows([...data.tasks].sort((a, b) => a.sortNo - b.sortNo).map(toRow));
const t2 = performance.now();
view.gantt.setData(data);
const t3 = performance.now();
say({
ko: `작업 ${count.toLocaleString('ko-KR')}개: 데이터 만들기 ${Math.round(t1 - t0)}ms · 표 ${Math.round(t2 - t1)}ms · gantt.setData ${Math.round(t3 - t2)}ms`,
en: `${count.toLocaleString('en-US')} tasks: build ${Math.round(t1 - t0)} ms · grid ${Math.round(t2 - t1)} ms · gantt.setData ${Math.round(t3 - t2)} ms`,
});
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
view = mountGantt(api);
load(api, 5000);
const unlink = view.gantt.attachGrid(api);
return () => {
unlink();
view?.destroy();
view = null;
};
}
export const actions = {
count: (api: GridApi<Row>, value?: string) => load(api, Number(value) || 5000),
}; 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/angular @maxgrid/gantt @maxgrid/gantt-core로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<select
aria-label="작업 수"
[disabled]="!api"
(change)="api && actions.count(api, $any($event.target).value)"
>
<option value="1000">1,000개</option>
<option value="5000" selected>5,000개</option>
</select>
</div>
<mx-grid style="height: 480px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import { createGantt, createSplitView } from '@maxgrid/gantt';
import { makeFixture } from '@maxgrid/gantt-core';
import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: string;
parentId: string | null;
wbs: string;
name: string;
assignee: string;
start: string;
end: string;
progress: number;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'wbs', title: 'WBS', width: 140 },
{ id: 'name', title: '작업', width: 300 },
{ id: 'assignee', title: '담당자', width: 110 },
{ id: 'start', title: '시작', width: 100 },
{ id: 'end', title: '종료', width: 100 },
{
id: 'progress',
title: '진행률(%)',
kind: 'number',
width: 90,
align: 'center',
cellRenderer: 'progressRing',
},
],
rows: [],
rowKey: 'id',
rowHeight: 40,
headerHeight: 48,
verticalScroll: 'external',
selection: 'single',
tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// 간트 작업을 표 행으로 바꿔요.
function toRow(t: {
id: string;
parentId: string | null;
wbsCode?: string;
name: string;
assigneeName?: string;
plannedStart: string | null;
plannedEnd: string | null;
progressPct: number;
}): Row {
return {
id: t.id,
parentId: t.parentId,
wbs: t.wbsCode ?? '',
name: t.name,
assignee: t.assigneeName ?? '',
start: t.plannedStart ?? '',
end: t.plannedEnd ?? '',
progress: t.progressPct,
};
}
// 표 옆에 간트 차트를 붙여요: 표 요소를 왼쪽 칸으로 옮기고 createSplitView로 묶어요.
function mountGantt(api: GridApi<Row>, ganttOptions: Parameters<typeof createGantt>[1] = {}) {
const gridEl = api.getGridElement();
// 깊이 18까지 이름이 읽히도록 들여쓰기 폭을 줄여요(기본 16px는 깊이 18에서 288px라 이름 칸을 다 채워요).
gridEl.style.setProperty('--mxg-indent', '6px');
const host = gridEl.parentElement as HTMLElement;
const box = document.createElement('div');
const left = document.createElement('div');
const right = document.createElement('div');
box.style.cssText = 'position: relative; width: 100%; height: 100%;';
box.append(left, right);
host.append(box);
left.append(gridEl);
const split = createSplitView({
left,
right,
container: box,
initial: 0.45,
min: box.clientWidth < 600 ? 110 : 240,
});
// 좁은 컨테이너(600px 미만)에서는 앞의 열만 남겨 차트 자리를 확보해요. 넓어지면 열이 돌아와요.
const fitColumns = (): void => {
const narrow = box.clientWidth < 600;
for (const id of ['assignee', 'start', 'end', 'progress']) api.setColumnVisible(id, !narrow);
api.resizeColumn('wbs', narrow ? 58 : 70);
};
fitColumns();
const fitObserver = new ResizeObserver(fitColumns);
fitObserver.observe(box);
const gantt = createGantt(right, {
rowHeight: 40,
barHeight: 24,
locale: 'ko',
verticalScroll: 'external',
...ganttOptions,
});
return {
gantt,
box,
right,
// 연결을 풀고 표를 원래 자리로 돌려놔요.
destroy() {
gantt.destroy();
fitObserver.disconnect();
split.destroy();
host.append(gridEl);
box.remove();
},
};
}
let view: ReturnType<typeof mountGantt> | null = null;
let say: (message: LogText) => void = () => {};
// 시험용 작업을 만들어 표와 차트에 넣고 걸린 시간을 적어요. 작업 id가 같아서 두 쪽이 행 키로 짝지어져요.
function load(api: GridApi<Row>, count: number) {
if (!view) return;
const t0 = performance.now();
const data = makeFixture({
tasks: count,
dependencies: Math.round(count * 1.2),
seed: 1,
startDate: '2026-10-05',
});
const t1 = performance.now();
api.setRows([...data.tasks].sort((a, b) => a.sortNo - b.sortNo).map(toRow));
const t2 = performance.now();
view.gantt.setData(data);
const t3 = performance.now();
say({
ko: `작업 ${count.toLocaleString('ko-KR')}개: 데이터 만들기 ${Math.round(t1 - t0)}ms · 표 ${Math.round(t2 - t1)}ms · gantt.setData ${Math.round(t3 - t2)}ms`,
en: `${count.toLocaleString('en-US')} tasks: build ${Math.round(t1 - t0)} ms · grid ${Math.round(t2 - t1)} ms · gantt.setData ${Math.round(t3 - t2)} ms`,
});
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
view = mountGantt(api);
load(api, 5000);
const unlink = view.gantt.attachGrid(api);
return () => {
unlink();
view?.destroy();
view = null;
};
}
export const actions = {
count: (api: GridApi<Row>, value?: string) => load(api, Number(value) || 5000),
}; This example needs an extra package. To run it locally, install with npm i maxgrid @maxgrid/gantt @maxgrid/gantt-core.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<select aria-label="Task count" id="count">
<option value="1000">1,000</option>
<option value="5000" selected>5,000</option>
</select>
</div>
<div id="grid" style="height: 480px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('count').addEventListener('change', (event) => actions.count(api, event.target.value));import { createGantt, createSplitView } from '@maxgrid/gantt';
import { makeFixture } from '@maxgrid/gantt-core';
export const options = {
columns: [
{ id: 'wbs', title: 'WBS', width: 140 },
{ id: 'name', title: 'Task', width: 300 },
{ id: 'assignee', title: 'Assignee', width: 110 },
{ id: 'start', title: 'Start', width: 100 },
{ id: 'end', title: 'End', width: 100 },
{
id: 'progress',
title: 'Progress (%)',
kind: 'number',
width: 90,
align: 'center',
cellRenderer: 'progressRing',
},
],
rows: [],
rowKey: 'id',
rowHeight: 40,
headerHeight: 48,
verticalScroll: 'external',
selection: 'single',
tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// Turn a Gantt task into a grid row.
function toRow(t) {
return {
id: t.id,
parentId: t.parentId,
wbs: t.wbsCode ?? '',
name: t.name,
assignee: t.assigneeName ?? '',
start: t.plannedStart ?? '',
end: t.plannedEnd ?? '',
progress: t.progressPct,
};
}
// Put the Gantt chart next to the grid: move the grid element into the left pane and join both with createSplitView.
function mountGantt(api, ganttOptions = {}) {
const gridEl = api.getGridElement();
// Narrow the indent so names stay readable at depth 18 (the default 16px would use 288px of the name column).
gridEl.style.setProperty('--mxg-indent', '6px');
const host = gridEl.parentElement;
const box = document.createElement('div');
const left = document.createElement('div');
const right = document.createElement('div');
box.style.cssText = 'position: relative; width: 100%; height: 100%;';
box.append(left, right);
host.append(box);
left.append(gridEl);
const split = createSplitView({
left,
right,
container: box,
initial: 0.45,
min: box.clientWidth < 600 ? 110 : 240,
});
// Narrow container (< 600 px): only the first columns stay so the chart keeps room; the rest come back when it widens.
const fitColumns = () => {
const narrow = box.clientWidth < 600;
for (const id of ['assignee', 'start', 'end', 'progress'])
api.setColumnVisible(id, !narrow);
api.resizeColumn('wbs', narrow ? 58 : 70);
};
fitColumns();
const fitObserver = new ResizeObserver(fitColumns);
fitObserver.observe(box);
const gantt = createGantt(right, {
rowHeight: 40,
barHeight: 24,
locale: 'en',
verticalScroll: 'external',
...ganttOptions,
});
return {
gantt,
box,
right,
// Unlink and put the grid back where it was.
destroy() {
gantt.destroy();
fitObserver.disconnect();
split.destroy();
host.append(gridEl);
box.remove();
},
};
}
let view = null;
let say = () => { };
// Build fixture tasks, load them into the grid and the chart, and log the time. Both sides share the task id as the row key.
function load(api, count) {
if (!view)
return;
const t0 = performance.now();
const data = makeFixture({
tasks: count,
dependencies: Math.round(count * 1.2),
seed: 1,
startDate: '2026-10-05',
});
const t1 = performance.now();
api.setRows([...data.tasks].sort((a, b) => a.sortNo - b.sortNo).map(toRow));
const t2 = performance.now();
view.gantt.setData(data);
const t3 = performance.now();
say(`${count.toLocaleString('en-US')} tasks: build ${Math.round(t1 - t0)} ms · grid ${Math.round(t2 - t1)} ms · gantt.setData ${Math.round(t3 - t2)} ms`);
}
export function setup(api, log) {
say = log;
view = mountGantt(api);
load(api, 5000);
const unlink = view.gantt.attachGrid(api);
return () => {
unlink();
view?.destroy();
view = null;
};
}
export const actions = {
count: (api, value) => load(api, Number(value) || 5000),
};This HTML also loads an extra bundle (the extra script tag above) and uses it as a global. No install is needed.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Draw 5,000 tasks with virtual scrolling</title>
</head>
<body>
<div class="toolbar">
<select aria-label="Task count" id="count">
<option value="1000">1,000</option>
<option value="5000" selected>5,000</option>
</select>
</div>
<div id="grid" style="height: 480px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<link rel="stylesheet" href="https://cdn.maxmine.com/maxgrid/latest/maxgrid.gantt.css" />
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.gantt.min.js"></script>
<script>
const { createGantt, createSplitView } = MaxGridGantt;
const { makeFixture } = MaxGridGantt;
const options = {
columns: [
{ id: 'wbs', title: 'WBS', width: 140 },
{ id: 'name', title: 'Task', width: 300 },
{ id: 'assignee', title: 'Assignee', width: 110 },
{ id: 'start', title: 'Start', width: 100 },
{ id: 'end', title: 'End', width: 100 },
{
id: 'progress',
title: 'Progress (%)',
kind: 'number',
width: 90,
align: 'center',
cellRenderer: 'progressRing',
},
],
rows: [],
rowKey: 'id',
rowHeight: 40,
headerHeight: 48,
verticalScroll: 'external',
selection: 'single',
tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// Turn a Gantt task into a grid row.
function toRow(t) {
return {
id: t.id,
parentId: t.parentId,
wbs: t.wbsCode ?? '',
name: t.name,
assignee: t.assigneeName ?? '',
start: t.plannedStart ?? '',
end: t.plannedEnd ?? '',
progress: t.progressPct,
};
}
// Put the Gantt chart next to the grid: move the grid element into the left pane and join both with createSplitView.
function mountGantt(api, ganttOptions = {}) {
const gridEl = api.getGridElement();
// Narrow the indent so names stay readable at depth 18 (the default 16px would use 288px of the name column).
gridEl.style.setProperty('--mxg-indent', '6px');
const host = gridEl.parentElement;
const box = document.createElement('div');
const left = document.createElement('div');
const right = document.createElement('div');
box.style.cssText = 'position: relative; width: 100%; height: 100%;';
box.append(left, right);
host.append(box);
left.append(gridEl);
const split = createSplitView({
left,
right,
container: box,
initial: 0.45,
min: box.clientWidth < 600 ? 110 : 240,
});
// Narrow container (< 600 px): only the first columns stay so the chart keeps room; the rest come back when it widens.
const fitColumns = () => {
const narrow = box.clientWidth < 600;
for (const id of ['assignee', 'start', 'end', 'progress'])
api.setColumnVisible(id, !narrow);
api.resizeColumn('wbs', narrow ? 58 : 70);
};
fitColumns();
const fitObserver = new ResizeObserver(fitColumns);
fitObserver.observe(box);
const gantt = createGantt(right, {
rowHeight: 40,
barHeight: 24,
locale: 'en',
verticalScroll: 'external',
...ganttOptions,
});
return {
gantt,
box,
right,
// Unlink and put the grid back where it was.
destroy() {
gantt.destroy();
fitObserver.disconnect();
split.destroy();
host.append(gridEl);
box.remove();
},
};
}
let view = null;
let say = () => { };
// Build fixture tasks, load them into the grid and the chart, and log the time. Both sides share the task id as the row key.
function load(api, count) {
if (!view)
return;
const t0 = performance.now();
const data = makeFixture({
tasks: count,
dependencies: Math.round(count * 1.2),
seed: 1,
startDate: '2026-10-05',
});
const t1 = performance.now();
api.setRows([...data.tasks].sort((a, b) => a.sortNo - b.sortNo).map(toRow));
const t2 = performance.now();
view.gantt.setData(data);
const t3 = performance.now();
say(`${count.toLocaleString('en-US')} tasks: build ${Math.round(t1 - t0)} ms · grid ${Math.round(t2 - t1)} ms · gantt.setData ${Math.round(t3 - t2)} ms`);
}
function setup(api, log) {
say = log;
view = mountGantt(api);
load(api, 5000);
const unlink = view.gantt.attachGrid(api);
return () => {
unlink();
view?.destroy();
view = null;
};
}
const actions = {
count: (api, value) => load(api, Number(value) || 5000),
};
options.ariaLabel = "Draw 5,000 tasks with virtual scrolling";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('count').addEventListener('change', (event) => actions.count(api, event.target.value));
</script>
</body>
</html> This example needs an extra package. To run it locally, install with npm i @maxgrid/react @maxgrid/gantt @maxgrid/gantt-core.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<select
aria-label="Task count"
disabled={!api}
onChange={(event) => api && actions.count(api, event.target.value)}
>
<option value="1000">1,000</option>
<option value="5000">5,000</option>
</select>
</div>
<Grid style={{ height: 480 }} ref={gridRef} options={options} />
</>
);
}import { createGantt, createSplitView } from '@maxgrid/gantt';
import { makeFixture } from '@maxgrid/gantt-core';
import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
export interface Row {
id: string;
parentId: string | null;
wbs: string;
name: string;
assignee: string;
start: string;
end: string;
progress: number;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'wbs', title: 'WBS', width: 140 },
{ id: 'name', title: 'Task', width: 300 },
{ id: 'assignee', title: 'Assignee', width: 110 },
{ id: 'start', title: 'Start', width: 100 },
{ id: 'end', title: 'End', width: 100 },
{
id: 'progress',
title: 'Progress (%)',
kind: 'number',
width: 90,
align: 'center',
cellRenderer: 'progressRing',
},
],
rows: [],
rowKey: 'id',
rowHeight: 40,
headerHeight: 48,
verticalScroll: 'external',
selection: 'single',
tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// Turn a Gantt task into a grid row.
function toRow(t: {
id: string;
parentId: string | null;
wbsCode?: string;
name: string;
assigneeName?: string;
plannedStart: string | null;
plannedEnd: string | null;
progressPct: number;
}): Row {
return {
id: t.id,
parentId: t.parentId,
wbs: t.wbsCode ?? '',
name: t.name,
assignee: t.assigneeName ?? '',
start: t.plannedStart ?? '',
end: t.plannedEnd ?? '',
progress: t.progressPct,
};
}
// Put the Gantt chart next to the grid: move the grid element into the left pane and join both with createSplitView.
function mountGantt(api: GridApi<Row>, ganttOptions: Parameters<typeof createGantt>[1] = {}) {
const gridEl = api.getGridElement();
// Narrow the indent so names stay readable at depth 18 (the default 16px would use 288px of the name column).
gridEl.style.setProperty('--mxg-indent', '6px');
const host = gridEl.parentElement as HTMLElement;
const box = document.createElement('div');
const left = document.createElement('div');
const right = document.createElement('div');
box.style.cssText = 'position: relative; width: 100%; height: 100%;';
box.append(left, right);
host.append(box);
left.append(gridEl);
const split = createSplitView({
left,
right,
container: box,
initial: 0.45,
min: box.clientWidth < 600 ? 110 : 240,
});
// Narrow container (< 600 px): only the first columns stay so the chart keeps room; the rest come back when it widens.
const fitColumns = (): void => {
const narrow = box.clientWidth < 600;
for (const id of ['assignee', 'start', 'end', 'progress']) api.setColumnVisible(id, !narrow);
api.resizeColumn('wbs', narrow ? 58 : 70);
};
fitColumns();
const fitObserver = new ResizeObserver(fitColumns);
fitObserver.observe(box);
const gantt = createGantt(right, {
rowHeight: 40,
barHeight: 24,
locale: 'en',
verticalScroll: 'external',
...ganttOptions,
});
return {
gantt,
box,
right,
// Unlink and put the grid back where it was.
destroy() {
gantt.destroy();
fitObserver.disconnect();
split.destroy();
host.append(gridEl);
box.remove();
},
};
}
let view: ReturnType<typeof mountGantt> | null = null;
let say: (message: LogText) => void = () => {};
// Build fixture tasks, load them into the grid and the chart, and log the time. Both sides share the task id as the row key.
function load(api: GridApi<Row>, count: number) {
if (!view) return;
const t0 = performance.now();
const data = makeFixture({
tasks: count,
dependencies: Math.round(count * 1.2),
seed: 1,
startDate: '2026-10-05',
});
const t1 = performance.now();
api.setRows([...data.tasks].sort((a, b) => a.sortNo - b.sortNo).map(toRow));
const t2 = performance.now();
view.gantt.setData(data);
const t3 = performance.now();
say(
`${count.toLocaleString('en-US')} tasks: build ${Math.round(t1 - t0)} ms · grid ${Math.round(t2 - t1)} ms · gantt.setData ${Math.round(t3 - t2)} ms`,
);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
view = mountGantt(api);
load(api, 5000);
const unlink = view.gantt.attachGrid(api);
return () => {
unlink();
view?.destroy();
view = null;
};
}
export const actions = {
count: (api: GridApi<Row>, value?: string) => load(api, Number(value) || 5000),
}; This example needs an extra package. To run it locally, install with npm i @maxgrid/vue @maxgrid/gantt @maxgrid/gantt-core.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<select
aria-label="Task count"
:disabled="!api"
@change="api && actions.count(api, ($event.target as HTMLSelectElement).value)"
>
<option value="1000">1,000</option>
<option value="5000" selected>5,000</option>
</select>
</div>
<Grid style="height: 480px" :options="options" @ready="onReady" />
</template>import { createGantt, createSplitView } from '@maxgrid/gantt';
import { makeFixture } from '@maxgrid/gantt-core';
import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
export interface Row {
id: string;
parentId: string | null;
wbs: string;
name: string;
assignee: string;
start: string;
end: string;
progress: number;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'wbs', title: 'WBS', width: 140 },
{ id: 'name', title: 'Task', width: 300 },
{ id: 'assignee', title: 'Assignee', width: 110 },
{ id: 'start', title: 'Start', width: 100 },
{ id: 'end', title: 'End', width: 100 },
{
id: 'progress',
title: 'Progress (%)',
kind: 'number',
width: 90,
align: 'center',
cellRenderer: 'progressRing',
},
],
rows: [],
rowKey: 'id',
rowHeight: 40,
headerHeight: 48,
verticalScroll: 'external',
selection: 'single',
tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// Turn a Gantt task into a grid row.
function toRow(t: {
id: string;
parentId: string | null;
wbsCode?: string;
name: string;
assigneeName?: string;
plannedStart: string | null;
plannedEnd: string | null;
progressPct: number;
}): Row {
return {
id: t.id,
parentId: t.parentId,
wbs: t.wbsCode ?? '',
name: t.name,
assignee: t.assigneeName ?? '',
start: t.plannedStart ?? '',
end: t.plannedEnd ?? '',
progress: t.progressPct,
};
}
// Put the Gantt chart next to the grid: move the grid element into the left pane and join both with createSplitView.
function mountGantt(api: GridApi<Row>, ganttOptions: Parameters<typeof createGantt>[1] = {}) {
const gridEl = api.getGridElement();
// Narrow the indent so names stay readable at depth 18 (the default 16px would use 288px of the name column).
gridEl.style.setProperty('--mxg-indent', '6px');
const host = gridEl.parentElement as HTMLElement;
const box = document.createElement('div');
const left = document.createElement('div');
const right = document.createElement('div');
box.style.cssText = 'position: relative; width: 100%; height: 100%;';
box.append(left, right);
host.append(box);
left.append(gridEl);
const split = createSplitView({
left,
right,
container: box,
initial: 0.45,
min: box.clientWidth < 600 ? 110 : 240,
});
// Narrow container (< 600 px): only the first columns stay so the chart keeps room; the rest come back when it widens.
const fitColumns = (): void => {
const narrow = box.clientWidth < 600;
for (const id of ['assignee', 'start', 'end', 'progress']) api.setColumnVisible(id, !narrow);
api.resizeColumn('wbs', narrow ? 58 : 70);
};
fitColumns();
const fitObserver = new ResizeObserver(fitColumns);
fitObserver.observe(box);
const gantt = createGantt(right, {
rowHeight: 40,
barHeight: 24,
locale: 'en',
verticalScroll: 'external',
...ganttOptions,
});
return {
gantt,
box,
right,
// Unlink and put the grid back where it was.
destroy() {
gantt.destroy();
fitObserver.disconnect();
split.destroy();
host.append(gridEl);
box.remove();
},
};
}
let view: ReturnType<typeof mountGantt> | null = null;
let say: (message: LogText) => void = () => {};
// Build fixture tasks, load them into the grid and the chart, and log the time. Both sides share the task id as the row key.
function load(api: GridApi<Row>, count: number) {
if (!view) return;
const t0 = performance.now();
const data = makeFixture({
tasks: count,
dependencies: Math.round(count * 1.2),
seed: 1,
startDate: '2026-10-05',
});
const t1 = performance.now();
api.setRows([...data.tasks].sort((a, b) => a.sortNo - b.sortNo).map(toRow));
const t2 = performance.now();
view.gantt.setData(data);
const t3 = performance.now();
say(
`${count.toLocaleString('en-US')} tasks: build ${Math.round(t1 - t0)} ms · grid ${Math.round(t2 - t1)} ms · gantt.setData ${Math.round(t3 - t2)} ms`,
);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
view = mountGantt(api);
load(api, 5000);
const unlink = view.gantt.attachGrid(api);
return () => {
unlink();
view?.destroy();
view = null;
};
}
export const actions = {
count: (api: GridApi<Row>, value?: string) => load(api, Number(value) || 5000),
}; This example needs an extra package. To run it locally, install with npm i @maxgrid/angular @maxgrid/gantt @maxgrid/gantt-core.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<select
aria-label="Task count"
[disabled]="!api"
(change)="api && actions.count(api, $any($event.target).value)"
>
<option value="1000">1,000</option>
<option value="5000" selected>5,000</option>
</select>
</div>
<mx-grid style="height: 480px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import { createGantt, createSplitView } from '@maxgrid/gantt';
import { makeFixture } from '@maxgrid/gantt-core';
import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string;
export interface Row {
id: string;
parentId: string | null;
wbs: string;
name: string;
assignee: string;
start: string;
end: string;
progress: number;
}
export const options: GridOptions<Row> = {
columns: [
{ id: 'wbs', title: 'WBS', width: 140 },
{ id: 'name', title: 'Task', width: 300 },
{ id: 'assignee', title: 'Assignee', width: 110 },
{ id: 'start', title: 'Start', width: 100 },
{ id: 'end', title: 'End', width: 100 },
{
id: 'progress',
title: 'Progress (%)',
kind: 'number',
width: 90,
align: 'center',
cellRenderer: 'progressRing',
},
],
rows: [],
rowKey: 'id',
rowHeight: 40,
headerHeight: 48,
verticalScroll: 'external',
selection: 'single',
tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// Turn a Gantt task into a grid row.
function toRow(t: {
id: string;
parentId: string | null;
wbsCode?: string;
name: string;
assigneeName?: string;
plannedStart: string | null;
plannedEnd: string | null;
progressPct: number;
}): Row {
return {
id: t.id,
parentId: t.parentId,
wbs: t.wbsCode ?? '',
name: t.name,
assignee: t.assigneeName ?? '',
start: t.plannedStart ?? '',
end: t.plannedEnd ?? '',
progress: t.progressPct,
};
}
// Put the Gantt chart next to the grid: move the grid element into the left pane and join both with createSplitView.
function mountGantt(api: GridApi<Row>, ganttOptions: Parameters<typeof createGantt>[1] = {}) {
const gridEl = api.getGridElement();
// Narrow the indent so names stay readable at depth 18 (the default 16px would use 288px of the name column).
gridEl.style.setProperty('--mxg-indent', '6px');
const host = gridEl.parentElement as HTMLElement;
const box = document.createElement('div');
const left = document.createElement('div');
const right = document.createElement('div');
box.style.cssText = 'position: relative; width: 100%; height: 100%;';
box.append(left, right);
host.append(box);
left.append(gridEl);
const split = createSplitView({
left,
right,
container: box,
initial: 0.45,
min: box.clientWidth < 600 ? 110 : 240,
});
// Narrow container (< 600 px): only the first columns stay so the chart keeps room; the rest come back when it widens.
const fitColumns = (): void => {
const narrow = box.clientWidth < 600;
for (const id of ['assignee', 'start', 'end', 'progress']) api.setColumnVisible(id, !narrow);
api.resizeColumn('wbs', narrow ? 58 : 70);
};
fitColumns();
const fitObserver = new ResizeObserver(fitColumns);
fitObserver.observe(box);
const gantt = createGantt(right, {
rowHeight: 40,
barHeight: 24,
locale: 'en',
verticalScroll: 'external',
...ganttOptions,
});
return {
gantt,
box,
right,
// Unlink and put the grid back where it was.
destroy() {
gantt.destroy();
fitObserver.disconnect();
split.destroy();
host.append(gridEl);
box.remove();
},
};
}
let view: ReturnType<typeof mountGantt> | null = null;
let say: (message: LogText) => void = () => {};
// Build fixture tasks, load them into the grid and the chart, and log the time. Both sides share the task id as the row key.
function load(api: GridApi<Row>, count: number) {
if (!view) return;
const t0 = performance.now();
const data = makeFixture({
tasks: count,
dependencies: Math.round(count * 1.2),
seed: 1,
startDate: '2026-10-05',
});
const t1 = performance.now();
api.setRows([...data.tasks].sort((a, b) => a.sortNo - b.sortNo).map(toRow));
const t2 = performance.now();
view.gantt.setData(data);
const t3 = performance.now();
say(
`${count.toLocaleString('en-US')} tasks: build ${Math.round(t1 - t0)} ms · grid ${Math.round(t2 - t1)} ms · gantt.setData ${Math.round(t3 - t2)} ms`,
);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
view = mountGantt(api);
load(api, 5000);
const unlink = view.gantt.attachGrid(api);
return () => {
unlink();
view?.destroy();
view = null;
};
}
export const actions = {
count: (api: GridApi<Row>, value?: string) => load(api, Number(value) || 5000),
};