### Install and Start React Gantt Project Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/README.md Clone the repository, install dependencies using yarn, and start the development server for local hosting. ```bash git clone https://github.com/dhtmlx/react-gantt-quick-start.git cd react-gantt-quick-start yarn yarn start ``` -------------------------------- ### Deploy to Netlify Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Install the Netlify CLI and execute the deploy command, specifying the production environment and the build output directory. ```bash npm install -g netlify-cli netlify deploy --prod --dir=dist ``` -------------------------------- ### Start Development Server Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Starts a local development server with hot module replacement for rapid development. Accessible at http://localhost:5173 by default. ```bash npm run dev # or yarn dev ``` -------------------------------- ### Installing Dependencies with npm or Yarn Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Commands to install all dependencies, only production dependencies, or add/update individual packages using npm or yarn. ```bash # Install all dependencies (production + dev) npm install # or yarn install # Install only production dependencies npm install --production # or yarn install --production # Add a new dependency npm install package-name # or yarn add package-name # Update a dependency npm update package-name # or yarn upgrade package-name ``` -------------------------------- ### Import Demo Data Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/00_START_HERE.txt Import sample tasks and links data from the demo data module. This is useful for initial setup and testing. ```javascript import { tasks, links } from './demoData'; ``` -------------------------------- ### Deploy to Vercel Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Install the Vercel CLI and run the deploy command. Vercel automatically detects Vite projects and deploys from the 'dist/' directory. ```bash npm install -g vercel vercel ``` -------------------------------- ### Build Commands for Development and Production Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/INDEX.md These commands are used for starting the development server, building the project for production, running code quality checks, and previewing the production build. ```bash npm run dev # Start dev server (http://localhost:5173) ``` ```bash npm run build # Type check + minify for production ``` ```bash npm run lint # ESLint code quality check ``` ```bash npm run preview # Preview production build ``` -------------------------------- ### Development Server Command Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/00_START_HERE.txt Start the development server using npm run dev. This command typically enables hot-reloading and other development-specific features. ```bash npm run dev ``` -------------------------------- ### Example Link Object Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/types.md Illustrates how to create a Link object for a finish-to-start dependency. This object can be included in the 'links' prop of the GanttChart component. ```typescript const link: Link = { id: 2, source: 2, target: 3, type: "0" // finish-to-start }; ``` -------------------------------- ### Callback Flow Example Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/module-reference.md Illustrates the sequence of events when a user interacts with the Gantt chart, specifically focusing on the save callback mechanism. ```text User edits task in Gantt ↓ Gantt library fires save callback ↓ Console logs event ↓ (No further action; not persisted) ``` -------------------------------- ### GanttChart Usage Example Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/api-reference.md Demonstrates how to use the GanttChart component within a React application, passing in task and link data. ```typescript import GanttChart from './components/Gantt/Gantt'; import { tasks, links } from './demoData'; function MyApp() { return (
); } ``` -------------------------------- ### Add Vite Bundle Analyzer Plugin Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Install the vite-plugin-visualizer to analyze your project's bundle size. This helps in identifying large dependencies. ```bash # Add vite-plugin-visualizer npm install -D vite-plugin-visualizer ``` -------------------------------- ### GanttChart Component Usage Example (TypeScript) Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/types.md Demonstrates how to import and use the GanttChart component with its props. Requires importing the GanttProps type for type checking. ```typescript import GanttChart from './components/Gantt/Gantt'; import type { GanttProps } from './components/Gantt/Gantt'; const props: GanttProps = { tasks: [], links: [] }; ``` -------------------------------- ### Example Task Object (TypeScript) Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/types.md Illustrates the creation of a project-type task object conforming to the Task type. Note the 'parent: 0' for root-level tasks. ```typescript const task: Task = { id: 1, text: "Office itinerancy", type: "project", start_date: new Date(2025, 3, 2), duration: 17, progress: 0.4, parent: 0, open: true }; ``` -------------------------------- ### Accessing Vite Environment Variables Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/configuration.md Example of checking the current environment mode using Vite's import.meta.env.DEV variable. ```typescript if (import.meta.env.DEV) { console.log('Development mode'); } ``` -------------------------------- ### Gantt Chart Container Styling Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/configuration.md Example of styling the Gantt chart container to fill the entire viewport using inline styles. ```jsx
``` -------------------------------- ### GanttConfig Properties Example Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/types.md Shows common properties used to configure the Gantt chart's grid and time scale. These settings control the layout and appearance of the chart. ```typescript const config: GanttConfig = { grid_width: 500, scale_height: 90, scales: [ { unit: 'year', step: 1, date: '%Y' }, { unit: 'month', step: 1, date: '%M' }, { unit: 'day', step: 1, date: '%d %M' } ] } ``` -------------------------------- ### Custom GanttConfig Example Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/types.md Demonstrates creating a custom GanttConfig object to adjust grid width, scale height, and define a specific month-based time scale. This configuration is passed to the 'config' prop of the Gantt component. ```typescript import type { GanttConfig } from '@dhtmlx/trial-react-gantt'; const customConfig: GanttConfig = { grid_width: 300, scale_height: 100, scales: [ { unit: 'month', step: 1, date: '%B %Y' } ] }; ``` -------------------------------- ### React DOM Root Initialization Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/api-reference.md Initializes the React root in the DOM and renders the main App component. This setup is standard for most React applications and is usually found in the entry file. ```typescript import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import './index.css' import App from './App.tsx' createRoot(document.getElementById('root')!).render( , ) ``` -------------------------------- ### Gantt Chart Configuration Object Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/INDEX.md Example of a GanttConfig object used to customize the Gantt chart's appearance and behavior. This includes settings for grid width, scale height, and time scale layers. ```typescript const config: GanttConfig = { grid_width: 500, // Left panel width (px) scale_height: 90, // Timeline header height (px) scales: [ // Time scale layers { unit: 'year', step: 1, date: '%Y' }, { unit: 'month', step: 1, date: '%M' }, { unit: 'day', step: 1, date: '%d %M' } ] }; ``` -------------------------------- ### Root TypeScript Configuration Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/module-reference.md Defines project references for a multi-root TypeScript setup, separating application code configuration from tooling configuration. Enables incremental compilation. ```json { "files": [], "references": [ { "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" } ] } ``` -------------------------------- ### Project Architecture Overview Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/overview.md Illustrates the directory structure of the React Gantt Quick-Start project, highlighting key files and their roles. ```tree src/ ├── main.tsx // React root initialization ├── App.tsx // Root component mounting GanttChart ├── components/ │ └── Gantt/ │ └── Gantt.tsx // GanttChart wrapper component └── demoData.tsx // Sample task and link data ``` -------------------------------- ### Override Gantt Grid Width Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/configuration.md Example CSS to override the default width of the Gantt chart grid. ```css /* Override grid width */ .gantt_grid { width: 400px !important; } ``` -------------------------------- ### Preview Production Build Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Serves the production build locally for testing before deployment. This command simulates the production environment's behavior. ```bash npm run preview # or yarn preview ``` -------------------------------- ### Override Gantt Timeline Header Height Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/configuration.md Example CSS to override the default height of the Gantt chart timeline header. ```css /* Override timeline header */ .gantt_task_scale { height: 120px; } ``` -------------------------------- ### Build Project for Bundle Analysis Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Run the build command to generate the bundle analysis report. The report will be available as stats.html in the dist directory. ```bash npm run build # stats.html is generated in dist/ ``` -------------------------------- ### Preview Production Build Command Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/00_START_HERE.txt Preview the production build of the project using npm run preview. This command serves the optimized build output locally. ```bash npm run preview ``` -------------------------------- ### Build for Production Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Performs a two-phase build process: first, type checking with TypeScript, then bundling and optimizing code with Vite for production. Output is generated in the 'dist/' directory. ```bash npm run build # or yarn build ``` -------------------------------- ### Build and Run Docker Container Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Commands to build a Docker image from the Dockerfile and run a container, exposing the application on port 3000. ```bash docker build -t react-gantt . docker run -p 3000:3000 react-gantt ``` -------------------------------- ### Deploy to AWS S3 + CloudFront Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Build the project, sync the 'dist/' directory to an S3 bucket, and create an invalidation for CloudFront. ```bash npm run build aws s3 sync dist/ s3://my-bucket/gantt/ aws cloudfront create-invalidation --distribution-id XXXXX --paths "/*" ``` -------------------------------- ### Build Project Command Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/00_START_HERE.txt Build the project for production using npm run build. This command usually performs type checking and minification. ```bash npm run build ``` -------------------------------- ### Product Launch Project Task Catalog Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/demo-data-reference.md This table lists all tasks and projects within the 'Product Launch' project, detailing their ID, text, type, dates, duration, progress, parent, and priority. ```markdown | ID | Text | Type | Start Date | Duration | Progress | Parent | Priority | Open | |----|----|------|-----------|----------|----------|--------|----------|------| | 11 | Product launch | project | 2025-04-02 | 13 | 0.6 | 0 | — | true | | 12 | Perform Initial testing | task | 2025-04-03 | 5 | 1.0 | 11 | — | — | | 14 | Analysis | task | 2025-04-03 | 6 | 0.8 | 11 | — | — | | 13 | Development | project | 2025-04-03 | 11 | 0.5 | 11 | — | true | | 17 | Develop System | task | 2025-04-03 | 2 | 1.0 | 13 | 2 | — | | 25 | Beta Release | milestone | 2025-04-06 | 0 | 0.0 | 13 | — | — | | 18 | Integrate System | task | 2025-04-10 | 2 | 0.8 | 13 | 3 | — | | 19 | Test | task | 2025-04-13 | 4 | 0.2 | 13 | — | — | | 20 | Marketing | task | 2025-04-13 | 4 | 0.0 | 13 | 1 | — | | 15 | Design | project | 2025-04-03 | 5 | 0.2 | 11 | — | true | | 21 | Design database | task | 2025-04-03 | 4 | 0.5 | 15 | — | — | | 22 | Software design | task | 2025-04-03 | 4 | 0.1 | 15 | 1 | — | | 23 | Interface setup | task | 2025-04-03 | 5 | 0.0 | 15 | 1 | — | | 16 | Documentation creation | task | 2025-04-03 | 7 | 0.0 | 11 | 1 | — | | 24 | Release v1.0 | milestone | 2025-04-18 | 0 | 0.0 | 11 | — | — | ``` -------------------------------- ### Customized Gantt Configuration Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/configuration.md Modify the Gantt configuration by editing the config object in `src/components/Gantt/Gantt.tsx`. This example shows changes to grid width, scale height, and scale layers. ```typescript const config: GanttConfig = { grid_width: 400, // Change to 400px scale_height: 100, // Change to 100px scales: [ { unit: 'month', step: 2, date: '%B %Y' }, // Show every 2 months { unit: 'day', step: 1, date: '%d' } ] }; ``` -------------------------------- ### Deploy to GitHub Pages Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Build the project and deploy the 'dist/' directory to the 'gh-pages' branch using the 'gh-pages' package. Ensure your 'package.json' includes the 'homepage' field. ```bash # Build the project npm run build # Deploy dist/ to gh-pages branch npm install -D gh-pages npx gh-pages -d dist ``` ```json { "homepage": "https://username.github.io/react-gantt-quick-start" } ``` -------------------------------- ### Module Dependencies Graph Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/overview.md Visualizes the module dependency graph for the React Gantt Quick-Start project, showing how different components and libraries interact. ```plaintext main.tsx → App.tsx → Gantt.tsx → @dhtmlx/trial-react-gantt (Gantt, ReactGanttRef, Task, Link, GanttConfig) → @dhtmlx/trial-react-gantt/dist/react-gantt.css → demoData.tsx → @dhtmlx/trial-react-gantt (Task, Link) ``` -------------------------------- ### Using ReactGanttRef for Component Access Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/types.md Demonstrates how to use `useRef` with `ReactGanttRef` to get a reference to the Gantt component instance. This allows programmatic access to Gantt methods and state after the component has mounted. ```typescript import { useRef } from 'react'; import Gantt, { ReactGanttRef } from '@dhtmlx/trial-react-gantt'; function MyComponent() { const ganttRef = useRef(null); const handleClick = () => { if (ganttRef.current) { // Access Gantt instance methods via ganttRef.current } }; return ; } ``` -------------------------------- ### Ensuring CSS Purging with Vite Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Demonstrates the correct way to import CSS files to ensure Vite's automatic CSS purging works effectively in production builds. ```typescript // ✅ Good: CSS imported where needed import "@dhtmlx/trial-react-gantt/dist/react-gantt.css"; // ❌ Avoid: CSS in unused dead code if (false) { import "./unused.css"; } ``` -------------------------------- ### Demo Data for Gantt Chart Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/INDEX.md Imports sample task and link data for demonstration purposes. This includes 24 sample Task objects and 9 sample Link objects. ```typescript import { tasks, links } from './demoData'; // 24 sample Task objects // 9 sample Link objects ``` -------------------------------- ### Dockerfile for Docker Deployment Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md A Dockerfile defining multi-stage builds for creating a production-ready Docker image. It first builds the application and then copies the static assets to a minimal runtime image. ```dockerfile # Build stage FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build # Runtime stage FROM node:20-alpine RUN npm install -g serve WORKDIR /app COPY --from=builder /app/dist ./ EXPOSE 3000 CMD ["serve", "-s", "dist", "-l", "3000"] ``` -------------------------------- ### Root App Component Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/api-reference.md This is the main entry point for the React application. It renders the GanttChart component with demo data. Typically, this component should not be imported elsewhere. ```typescript export default function App(): JSX.Element ``` ```typescript import App from './App'; ``` -------------------------------- ### Running NPM/Yarn Scripts Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/configuration.md Common commands to run scripts defined in package.json for development, building, linting, and previewing the application. ```bash # Start development server ``` ```bash npm run dev ``` ```bash yarn dev ``` ```bash # Build for production ``` ```bash npm run build ``` ```bash yarn build ``` ```bash # Check code quality ``` ```bash npm run lint ``` ```bash yarn lint ``` ```bash # Preview production build ``` ```bash npm run preview ``` ```bash yarn preview ``` -------------------------------- ### Project Dependencies Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/module-reference.md Lists the project's runtime dependencies, including the React Gantt component, React, and ReactDOM. ```json { "dependencies": { "@dhtmlx/trial-react-gantt": "^9.1.1", "react": "^19.2.0", "react-dom": "^19.2.0" } } ``` -------------------------------- ### Demo Data Import Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/README.md Imports sample task and link data for the Gantt chart. This provides pre-defined data for demonstration purposes. ```typescript import { tasks, links } from './demoData'; // tasks: Task[] — 24 sample tasks // links: Link[] — 9 sample dependencies ``` -------------------------------- ### Package.json Metadata Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/module-reference.md Defines project metadata, including name, type, main entry point, and scripts for development and building. ```json { "name": "react-gantt-quick-start", "type": "module", "main": "(not specified)", "scripts": { "start": "...", "dev": "...", "build": "...", "lint": "...", "preview": "..." } } ``` -------------------------------- ### Import Demo Data for DHTMLX React Gantt Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/demo-data-reference.md Import the predefined tasks and links from the demo data file. Ensure you have the correct type definitions for Task and Link. ```typescript import { tasks, links } from './demoData'; import type { Task, Link } from '@dhtmlx/trial-react-gantt'; // tasks is Task[] // links is Link[] ``` -------------------------------- ### Configuring Asset Optimization in Vite Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Customize Vite's build settings for asset optimization, including inlining small assets and specifying the output directory. ```typescript // vite.config.ts export default defineConfig({ build: { assetsInlineLimit: 4096, // Inline assets <4KB as data URIs assetsDir: 'assets', // Output directory for assets } }) ``` -------------------------------- ### Project Dev Dependencies Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/module-reference.md Lists the project's development dependencies, including TypeScript, Vite, and ESLint plugins. ```json { "devDependencies": { "typescript": "~5.9.3", "vite": "^7.3.2", "eslint": "...", "@vitejs/plugin-react": "...", "eslint-plugin-react-hooks": "...", "eslint-plugin-react-refresh": "..." } } ``` -------------------------------- ### Vite Build Configuration Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/configuration.md Basic Vite configuration for a React project using the @vitejs/plugin-react plugin. ```typescript import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], }) ``` -------------------------------- ### Real-time Updates for Multi-User Collaboration Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/integration-guide.md Set up real-time updates for multi-user collaboration by subscribing to database changes (e.g., using Supabase channels). This allows the Gantt chart to reflect changes made by other users in real-time. ```typescript // Subscribe to real-time updates useEffect(() => { const channel = supabase .channel('gantt-updates') .on('postgres_changes', { event: '*', schema: 'public', table: 'tasks' }, (payload) => { // Update local state from payload handleRemoteUpdate(payload); } ) .subscribe(); return () => { supabase.removeChannel(channel); }; }, []); ``` -------------------------------- ### Customizing Code Splitting with Vite Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Configure Vite's build output to manually split code into vendor and Gantt chunks for better performance. ```typescript // vite.config.ts export default defineConfig({ build: { rollupOptions: { output: { manualChunks: { 'vendor': ['react', 'react-dom'], 'gantt': ['@dhtmlx/trial-react-gantt'] } } } } }) ``` -------------------------------- ### External Library Imports for DHTMLX Gantt Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/overview.md Demonstrates the necessary imports from the `@dhtmlx/trial-react-gantt` library and its CSS file for integrating DHTMLX Gantt into a React application. ```typescript import Gantt, { ReactGanttRef, Task, Link, GanttConfig } from '@dhtmlx/trial-react-gantt'; import "@dhtmlx/trial-react-gantt/dist/react-gantt.css"; ``` -------------------------------- ### Export Sample Tasks Data Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/api-reference.md Exports an array of sample Gantt task objects. Use this to initialize the Gantt chart with predefined tasks and projects. ```typescript export const tasks: Task[] ``` ```typescript import { tasks } from './demoData'; const completedTasks = tasks.filter(t => t.progress === 1); const projectTasks = tasks.filter(t => t.type === 'project'); ``` -------------------------------- ### Configure Vite for Bundle Analysis Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Integrate the visualizer plugin into your vite.config.ts file to enable bundle analysis. After building, a stats.html file will be generated. ```typescript import { visualizer } from 'vite-plugin-visualizer'; export default defineConfig({ plugins: [react(), visualizer()] }) ``` -------------------------------- ### Lint Project Command Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/00_START_HERE.txt Run ESLint to check for code style and potential errors using npm run lint. This helps maintain code quality. ```bash npm run lint ``` -------------------------------- ### Import Gantt CSS Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/README.md Ensure the Gantt CSS is imported correctly to enable proper styling and rendering of the Gantt chart. ```javascript import "@dhtmlx/trial-react-gantt/dist/react-gantt.css" ``` -------------------------------- ### Reinstall Dependencies Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/README.md Clear the node_modules directory and reinstall dependencies to resolve potential build failures caused by corrupted or outdated packages. ```bash rm -rf node_modules && npm install ``` -------------------------------- ### Production Dependencies for React Gantt Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md List of packages required to run the application in production. Includes the Gantt library, React, and ReactDOM. ```json { "@dhtmlx/trial-react-gantt": "^9.1.1", "react": "^19.2.0", "react-dom": "^19.2.0" } ``` -------------------------------- ### Office Project Chain Dependency Visualization Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/demo-data-reference.md Visual representation of task dependencies in the Office Project Chain. Shows the sequence and relationships between tasks. ```text Office Facing (2, Apr 2-9) ↓ [Link 2] Furniture Installation (3, Apr 11-18) ↓ [Link 3] Employee Relocation (4, Apr 13-17) ├─ Preparing Workplaces (8, Apr 14-18) │ ↓ [Link 7] ├─ Workplaces Importation (9, Apr 21-24) │ ↓ [Link 8] └─ Workplaces Exportation (10, Apr 27-29) ``` -------------------------------- ### Display Kanban and Gantt Side-by-Side Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/integration-guide.md Integrate Kanban and Gantt charts in a side-by-side layout using flexbox for a project management view. This allows users to see tasks in both list and timeline formats. ```typescript function ProjectManagement() { const [tasks, setTasks] = useState([]); const [links, setLinks] = useState([]); return (
); } ``` -------------------------------- ### Separate Development Milestone Visualization Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/demo-data-reference.md Shows a separate development milestone and its dependency link, illustrating a distinct chain within the project. ```text Development (13, Apr 3-13) ↓ [Link 22] Release v1.0 (24, Apr 18, milestone) ``` -------------------------------- ### Initialize DHTMLX React Gantt Component Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/README.md Declaratively initialize the Gantt component with tasks, links, and custom configuration. Includes a basic data save handler. ```tsx import { useRef } from 'react'; import Gantt, { ReactGanttRef, Task, Link, GanttConfig } from '@dhtmlx/trial-react-gantt'; import "@dhtmlx/trial-react-gantt/dist/react-gantt.css"; export interface GanttProps { tasks: Task[]; links: Link[]; } export default function GanttChart({ tasks, links }: GanttProps) { const ganttRef = useRef(null); const config: GanttConfig = { grid_width: 500, scale_height: 90, scales: [ { unit: 'year', step: 1, date: '%Y' }, { unit: 'month', step: 1, date: '%M' }, { unit: 'day', step: 1, date: '%d %M' } ] }; return ( { console.log(`${entity} - ${action} - ${id}`, data); } }} /> ); } ``` -------------------------------- ### Implement Responsive Gantt Container Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/integration-guide.md Use React's `useRef` and `useState` hooks to create a responsive container for the Gantt chart. This ensures the chart adapts to different screen sizes. ```typescript function App() { const containerRef = useRef(null); const [dimensions, setDimensions] = useState({ width: 0, height: 0 }); useEffect(() => { const handleResize = () => { if (containerRef.current) { setDimensions({ width: containerRef.current.offsetWidth, height: containerRef.current.offsetHeight }); } }; handleResize(); window.addEventListener('resize', handleResize); return () => window.removeEventListener('resize', handleResize); }, []); return (
{dimensions.width > 0 && ( )}
); } ``` -------------------------------- ### Build Environment Variables with .env files Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Define environment variables in .env files for different build modes (all, development, production). These variables can be accessed in the application code via import.meta.env. ```bash # .env (loaded in all modes) VITE_APP_TITLE=Gantt Demo # .env.development (dev server only) VITE_API_URL=http://localhost:3000 # .env.production (build only) VITE_API_URL=https://api.example.com ``` ```typescript const appTitle = import.meta.env.VITE_APP_TITLE; const apiUrl = import.meta.env.VITE_API_URL; ``` -------------------------------- ### Export Sample Links Data Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/api-reference.md Exports an array of sample Gantt link objects, defining task dependencies. Use this to establish sequencing between tasks on the Gantt chart. ```typescript export const links: Link[] ``` ```typescript import { links } from './demoData'; // Find all dependencies for a specific task const taskDependencies = links.filter(l => l.source === 5); // Get all blocking tasks const blockingTasks = links.map(l => l.source); ``` -------------------------------- ### Define App Component Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/module-reference.md Defines the root App component which renders the GanttChart with demo data. It uses inline styles for full viewport coverage. ```typescript import GanttChart from './components/Gantt/Gantt.tsx'; import { tasks, links } from './demoData'; export default function App() { return (
); } ``` -------------------------------- ### Memoize Gantt Tasks and Links Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/integration-guide.md Use `useMemo` to memoize tasks and links for performance optimization when they are passed as props to the Gantt chart component. This prevents unnecessary re-renders if the data hasn't changed. ```typescript import { useMemo } from 'react'; import GanttChart from './components/Gantt/Gantt'; function App({ tasks, links }) { const memoizedTasks = useMemo(() => tasks, [tasks]); const memoizedLinks = useMemo(() => links, [links]); return ( ); } ``` -------------------------------- ### Development Dependencies for React Gantt Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/build-and-deployment.md Packages needed only during the development phase, including TypeScript, ESLint, Vite, and React plugins. ```json { "@types/react": "^19.2.7", "@types/react-dom": "^19.2.3", "@vitejs/plugin-react": "^5.1.1", "@eslint/js": "^9.39.1", "eslint": "^9.39.1", "eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-refresh": "^0.4.24", "globals": "^16.5.0", "typescript": "~5.9.3", "typescript-eslint": "^8.48.1", "vite": "^7.3.2" } ``` -------------------------------- ### Task Hierarchy Visualization Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/demo-data-reference.md This section displays the hierarchical structure of tasks and projects within the demo data. It outlines parent-child relationships and project containment. ```text Project 1: Office Itinerancy (id: 1) ├─ Project 1.1: Office Facing (id: 2) │ ├─ Task: Interior Office (id: 5) │ └─ Task: Air Conditioners Check (id: 6) ├─ Project 1.2: Furniture Installation (id: 3) │ └─ Task: Workplaces Preparation (id: 7) └─ Project 1.3: Employee Relocation (id: 4) ├─ Task: Preparing Workplaces (id: 8) ├─ Task: Workplaces Importation (id: 9) └─ Task: Workplaces Exportation (id: 10) Project 2: Product Launch (id: 11) ├─ Task: Perform Initial Testing (id: 12) ├─ Task: Analysis (id: 14) ├─ Project 2.1: Development (id: 13) │ ├─ Task: Develop System (id: 17) │ ├─ Milestone: Beta Release (id: 25) │ ├─ Task: Integrate System (id: 18) │ ├─ Task: Test (id: 19) │ └─ Task: Marketing (id: 20) ├─ Project 2.2: Design (id: 15) │ ├─ Task: Design Database (id: 21) │ ├─ Task: Software Design (id: 22) │ └─ Task: Interface Setup (id: 23) ├─ Task: Documentation Creation (id: 16) └─ Milestone: Release v1.0 (id: 24) ``` -------------------------------- ### Paginate Large Datasets for Gantt Chart Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/integration-guide.md Implement pagination to handle large datasets by slicing tasks based on page size and current page. This improves performance by only rendering a subset of tasks at a time. ```typescript const [pageSize] = useState(50); const [page, setPage] = useState(0); const visibleTasks = tasks.slice( page * pageSize, (page + 1) * pageSize ); ``` -------------------------------- ### Fetch Gantt Data on Component Mount Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/integration-guide.md Use this pattern to load initial task and link data when the Gantt chart component is first rendered. It fetches data from separate API endpoints for tasks and links. ```typescript import { useEffect, useState } from 'react'; import GanttChart from './components/Gantt/Gantt'; import { Task, Link } from '@dhtmlx/trial-react-gantt'; function App() { const [tasks, setTasks] = useState([]); const [links, setLinks] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function loadData() { try { const [tasksRes, linksRes] = await Promise.all([ fetch('/api/tasks'), fetch('/api/links') ]); const tasksData = await tasksRes.json(); const linksData = await linksRes.json(); setTasks(tasksData); setLinks(linksData); } catch (error) { console.error('Failed to load data', error); } finally { setLoading(false); } } loadData(); }, []); if (loading) return
Loading...
; return (
); } ``` -------------------------------- ### Environment-Based Configuration for Gantt Source: https://github.com/dhtmlx/react-gantt-quick-start/blob/main/_autodocs/integration-guide.md Create a function to generate Gantt configurations based on the environment (e.g., development or production). This is useful for applying different settings like read-only modes or adjusted grid widths. ```typescript // config.ts export const getConfig = (env: 'dev' | 'prod'): GanttConfig => { const baseConfig = { grid_width: 500, scales: [/* ... */] }; if (env === 'prod') { return { ...baseConfig, grid_width: 400, // Narrower for production readonly: true // Read-only in production }; } return baseConfig; }; ``` ```typescript import { getConfig } from '../config'; const config = getConfig(import.meta.env.PROD ? 'prod' : 'dev'); ```