project-tasks-js: Project Tasks (1k to 1M tasks on a Gantt)
The Gantt demo: no backend, no network calls. A single <vn-gantt> fed a
client-generated project plan through VanillaGanttStaticDataManager:
1,000 tasks by default, up to 1,000,000. It shows the Gantt
(docs/vanilla-gantt/00-index.md): a
task tree in an embedded <vn-grid>, and a timeline with one bar per row the
grid renders.
What it shows
- A three-level plan. Phases, each with 10 work packages of 9 tasks. Within
a work package the tasks run one after the other, 1 to 5 days each, and the
last one is a milestone (
end == start), drawn as a diamond. Work packages start 5 days apart and phases are staggered, wrapping every ten years, so the plan spans about a decade at any size. Phases and work packages carry no dates of their own: the Gantt rolls them up from their tasks and shows them as summary brackets. - Dependency links. Each task is linked to the one before it in its work package (finish-to-start, about one link per row), and every 20th phase's last milestone to the first task of the phase 30 phases later. Where the phases' ten-year stagger wraps around, a long link ends before it starts and shows as violated. Collapse a work package to see its outgoing link redrawn, dashed, from the package's summary bar.
- Moving tasks. Drag a bar (or hold it, on touch), or select its task,
focus the timeline and press
Shift+ArrowLeft/Shift+ArrowRight: the tasks after it in its work package are pushed, the summaries roll up, and the toolbar's status message reports how many other tasks changed. A move that would go round a dependency cycle is refused, and the status message says so, as an error. - One frame, with a splitter. The task list starts 880px wide
(
initializeGantt({ taskListWidth: 880 })), and its columns fill it:index.htmldeclares the five built-in columns (Task, Start, End, Duration, Id) as<vn-grid-column gantt-value="...">children of<vn-gantt>, with Task widened to 187px, and the two custom columns below between Duration and Id; drag the line between the panes, or focus it and use the arrow keys, Home and End, to resize them. The task grid's vertical scrollbar sits at the timeline's right edge, widens while the pointer is over either pane, and a wheel over it scrolls the tasks. - Custom columns. Two markup columns over fields the plan generator
adds to every task: Progress (
progress, 0 to 100) and Assigned to (assignee, a made-up name; a summary has none). Within a work package the first tasks are done, the next is under way and the rest not started; a summary's progress is its children's mean. Progress shows a small pie that fills clockwise with the percentage, up to its ring (a solid disc at 100%), in the Gantt theme's bar colour, then the number: a markup column can't carry a function, soapp.jssets therenderCellon the task grid's live column (getTaskGrid().grid.getColumn('progress')) right afterinitializeGantt(). It staystype="number", so both columns sort and filter on the raw values. The search looks at the assignees (below), not at the progress. - A resizable frame. The toolbar and the Gantt sit in one
<vn-resize-box>(min-width="1050" min-height="300", as in file-system-js): drag its bottom-right corner to resize both together, or double-click it to maximize and restore. The minimum width leaves the timeline its 160px minimum beside the 880px task list, so the task list keeps its width and the timeline gives way. The lanes stay level with their rows and the task list keeps its scroll position. The handle follows the Gantt's theme through its task grid, with no code. - Both axes virtualized. At 1,000,000 tasks the grid scrolls in scaled mode and the timeline follows it row for row; the DOM holds as many lanes as the grid's row pool and only the header ticks near the view.
- Zoom. The zoom selector sets
day,week,month,quarteroryear; it followsvn-gantt-zoom-changed, so a level the plan is too long for shows the level the Gantt clamped to. - Theme. The theme selector switches the Gantt between
defaultanddefault-dark(both panes, and the toolbar, which follows the grid's theme) and swaps the page chrome's shared app theme (../_common/themes/app-*.css). - A toolbar bound to the task grid.
<vn-gantt-toolbar gantt="projectGantt">names the Gantt in markup: it waits for the Gantt and links its task grid onceapp.jsinitializes it, with no link code. It is a<vn-grid-toolbar>with that one link added, so every item is a standard one: the status, a status message and an info button (below), the search box, Expand all and Collapse all (expandAllRows/collapseAllRows, shown by theisTreeModestate) and clear filters and sorting, plus the Gantt toolbar's own Scroll to task (below) and Auto-fit columns and task list (autoFitTaskList). Auto-fit sizes each task-list column to its header and the rows on screen, the Progress pie included, then moves the splitter to the last column's right edge, as far as the timeline's minimum width allows (wider columns scroll sideways). Between fits the splitter and the columns are independent; a double-click on the splitter fits the task list to the columns as they are. - Keyboard. Tab crosses the Gantt in three stops, the task list, the splitter and the timeline, however many tasks are loaded.
- Selecting a task, then scrolling to it. A click on a row or a bar,
Space (the first fully visible task), or the arrows, pages, Home and End
with the pointer over either pane, select one task; both panes show it, the
row and its lane in the same tint, the row's selection marker and a ring
around its bar, and a hovered task the same way, and the timeline scrolls
sideways to its bar. With nothing selected those keys scroll both panes;
Space again clears the selection. In the task list, ArrowRight and
ArrowLeft expand and collapse the selected task, or move to its first child
or its parent. Scroll to task
(
scrollToSelectedTask, enabled by thehasSingleSelectionstate) expands its ancestors, centres its row, brings its bar back into view and focuses the timeline. The toolbar has noselectedtemplate, so the search stays while a task is selected. - Search and filters. The search box matches task names, ids and
assignees (
initializeGantt({ searchFields: ['name', 'id', 'assignee'] }); its hint reads "Searching: Task, Id, and Assigned to"), keeping each match's phase and work package as context, and marks the match in the names, ids and assignees (initializeGantt({ highlightSearchMatches: true })). Every column filters from its header; the Duration filter compares days. - Task details. A double-click on a task, on its row in the task list or
on its bar (a double tap, on touch), opens a read-only side panel from
vn-gantt-task-dblclick: its id, kind (task, milestone or summary), start, end and duration as the task grid shows them, its parent's name and id, and a small table each of its predecessors and successors: the other task's id and name, and the link's type (FS,SS,FF,SF), one row per link, or "None". The kind and the links come from one scan of the manager's tasks and links when the panel opens, so the load builds no index for them. The close button, a click beside the panel or Escape close it; aShift+Arrowmove of the task shown updates it. The panel copies the details panel ofgithub-repos-js. - Messages in the toolbar. There is no status line under the Gantt.
Beside the row count, the info button (
<vn-grid-toolbar-info>) shows the link count and the load time fromvn-gantt-loadedas a tooltip (setInfoMessage()), and the status message (<vn-grid-toolbar-status-message>,setStatusMessage()) shows each move fromvn-gantt-task-moved, then a refused or undone move fromvn-gantt-task-move-failedand a load that failed, tinted as errors. A Gantt that could not start never links the toolbar, so the toolbar'sunlinkedtemplate holds a status message too, and shows that error. - Loading overlay. A spinner over the whole page, as in large-dataset-js: visible in the markup, so it paints before the plan generation blocks the main thread, and hidden once the tasks are loaded (or the load fails). The size selector reloads the page, so it shows again for the new size.
Script load order
The grid's vanilla-grid.js first: the Gantt embeds a <vn-grid> and reads
the grid's utilities at runtime. Then vanilla-grid-toolbar.js and
vanilla-gantt.js, each auto-loading its own files, vanilla-gantt-toolbar.js,
which extends the grid toolbar and so comes after it, vanilla-resize-box.js,
which depends on none of them, and app.js, a module, last. npm run build
rewrites the five tags to the shared bundles in place, keeping that order.
Run
Serve the workspace root with any static server, then open
/samples/project-tasks-js/index.html. No backend or network access is needed.
?tasks=1000, ?tasks=100000 or ?tasks=1000000 sets the plan size; the size
selector reloads the page with it.
Files
index.html: the loading overlay, the header with the theme, zoom and size selectors, the<vn-resize-box>around the toolbar and the Gantt, the toolbar templates (unlinked, andemptywith the Scroll to task button), the<vn-gantt>with its seven column elements, the task details panel and its backdrop, the script load order.app.js:type="module"bootstrap. Generates the plan (seeded, so a size always gives the same plan, with each task's progress and assignee) and its links, sets the manager, initializes the Gantt (which links the toolbar), sets the Progress column's renderer, loads, hides the loading overlay, and wires the selectors, the toolbar's status message and info, and the task details panel.styles.css: the page layout (the resize box included), the loading overlay, the Progress column's pie and the task details panel; colours come from the shared app theme, but the overlay's, which are fixed, as in large-dataset-js, and the panel's, which the app themes don't style (light, or the dark theme's container colours underdefault-dark).