Gantt
Tasks on a calendar: their list on the left, a tree of groups, their bars on the right, with milestones and arrows between them. The pointer moves a bar, stretches it, changes its progress; ctrl+wheel zooms. Not in x4js: it is imported from x4js/gantt.
import { Gantt, GanttTask } from "x4js/gantt"
A project
Groups and their tasks, milestones, deps drawn as arrows; columns are the list on the left. The pointer moves a bar, stretches it by its ends, its progress by the mark under it: change tells it before it is written in the task.
export function tasks( ) {
const result = new Label( { text: "Move a bar" } );
return new VBox( { content: [
new Gantt( { width: "100%", height: 360, tasks: project( ),
columns: [
{ id: "title", width: 180 },
{ id: "start", width: 100 },
{ id: "end", width: 100 },
],
click: ( ev ) => result.setText( "click: " + ( ev.context as GanttTask ).title ),
change: ( ev ) => result.setText( `change: ${ev.task.title}, ${formatDate( ev.start )} - ${formatDate( ev.end )}, ${ev.progress} %` ),
} ),
result,
] } );
}
Scales
scale is the width of a day: hours, days, weeks or months. ctrl+wheel on the chart zooms, the day under the pointer stays: scaleChange tells the scale it took. scrollToDate brings a day in the middle.
export function scales( ) {
const scale = new Select( { value: "day", change: ( ev ) => gantt.setScale( ev.value as GanttScale ), items: [
{ id: "hour", text: "Hours" },
{ id: "day", text: "Days" },
{ id: "week", text: "Weeks" },
{ id: "month", text: "Months" },
] } );
const gantt = new Gantt( { width: "100%", height: 300, tasks: project( ),
scaleChange: ( ev ) => scale.setValue( ev.scale ),
} );
return new VBox( { content: [
new HBox( { content: [
scale,
new Button( { label: "Today", cls: "outline", click: ( ) => gantt.scrollToDate( new Date( ) ) } ),
] } ),
gantt,
] } );
}
Colors and tooltips
color is the bar of a task: a group gives its own to its tasks that have none, a task may have another one; without color, the theme. tooltip is shown over the bar.
export function colors( ) {
return new Gantt( { width: "100%", height: 230, tasks: [
{ id: "dev", title: "Development", color: "#fb8c00", children: [
{ id: "core", title: "Core", start: day( 0 ), end: day( 8 ), progress: 30, tooltip: "The engine: <b>2 developers</b>" },
{ id: "api", title: "Server API", start: day( 2 ), end: day( 7 ), progress: 50 },
{ id: "ui", title: "User interface", start: day( 4 ), end: day( 14 ), color: "#e53935", deps: [ "api" ] },
] },
{ id: "doc", title: "Documentation", children: [
{ id: "guide", title: "Guide", start: day( 6 ), end: day( 12 ) },
] },
] } );
}
Read only, disabled
setReadOnly( true ): no bar is moved. enable( false ): faded, as a Box.
export function readOnly( ) {
const gantt = new Gantt( { width: "100%", height: 300, tasks: project( ) } );
return new VBox( { content: [
new HBox( { content: [
new Checkbox( { label: "Read only", change: ( ev ) => gantt.setReadOnly( ev.value ) } ),
new Checkbox( { label: "Disabled", change: ( ev ) => gantt.enable( !ev.value ) } ),
] } ),
gantt,
] } );
}
For an assistant: llms.txt, llms-full.txt.