A modern, lightweight web component wrapper for ApexGantt, built with Lit. Create interactive Gantt charts with minimal setup and maximum flexibility.
- 🎯 Framework Agnostic - Works with React, Vue, Angular, or vanilla JavaScript
- 🚀 Lightweight - Built on Lit for optimal performance
- 🎨 Fully Customizable - Extensive configuration options
- 📱 Responsive - Adapts to different screen sizes
- 🔄 Dynamic Updates - Update tasks and options on the fly
- 📊 Zoom Controls - Built-in zoom in/out functionality
- 🎯 TypeScript Support - Full type definitions included
npm install apexgantt-webcomponentimport { ApexGanttChart } from 'apexgantt-webcomponent';
// Register the custom element
ApexGanttChart.register();<apex-gantt-chart id="gantt"></apex-gantt-chart>const ganttChart = document.querySelector('#gantt');
ganttChart.options = {
tasks: [
{
id: '1',
name: 'Project Planning',
start: '2025-01-01',
end: '2025-01-15',
progress: 100
},
{
id: '2',
name: 'Development',
start: '2025-01-16',
end: '2025-03-31',
progress: 45,
dependencies: '1'
},
{
id: '3',
name: 'Testing',
start: '2025-04-01',
end: '2025-04-30',
progress: 0,
dependencies: '2'
}
],
viewMode: 'Week'
};import { useEffect, useRef } from 'react';
import { ApexGanttChart } from 'apexgantt-webcomponent';
// Register once in your app
ApexGanttChart.register();
function GanttComponent() {
const ganttRef = useRef(null);
useEffect(() => {
if (ganttRef.current) {
ganttRef.current.options = {
tasks: [
// Your tasks here
],
viewMode: 'Month'
};
}
}, []);
return <apex-gantt-chart ref={ganttRef} />;
}<template>
<apex-gantt-chart ref="ganttRef"></apex-gantt-chart>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { ApexGanttChart } from 'apexgantt-webcomponent';
// Register once in your app
ApexGanttChart.register();
const ganttRef = ref(null);
onMounted(() => {
ganttRef.value.options = {
tasks: [
// Your tasks here
],
viewMode: 'Day'
};
});
</script>import { Component, OnInit, ViewChild, ElementRef, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ApexGanttChart } from 'apexgantt-webcomponent';
// Register once in your app (e.g., in main.ts)
ApexGanttChart.register();
@Component({
selector: 'app-gantt',
template: '<apex-gantt-chart #gantt></apex-gantt-chart>',
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class GanttComponent implements OnInit {
@ViewChild('gantt') gantt!: ElementRef;
ngOnInit() {
this.gantt.nativeElement.options = {
tasks: [
// Your tasks here
]
};
}
}Type: GanttUserOptions
The main configuration object for the Gantt chart. Includes tasks, view mode, and other settings.
ganttChart.options = {
tasks: [...],
viewMode: 'Week',
// Additional configuration options
};Updates a specific task with new data.
ganttChart.updateTask('task-1', {
progress: 75,
end: '2025-02-15'
});Updates the entire Gantt chart configuration.
ganttChart.updateOptions({
tasks: [...],
viewMode: 'Month'
});Zooms in the Gantt chart (Year → Quarter → Month → Week → Day).
ganttChart.zoomIn();Zooms out the Gantt chart (Day → Week → Month → Quarter → Year).
ganttChart.zoomOut();The component emits the following custom events:
gantt-task-update- Fired when a task is being updatedgantt-task-update-success- Fired when a task update succeedsgantt-task-update-error- Fired when a task update failsgantt-task-validation-error- Fired when task validation fails
ganttChart.addEventListener('gantt-task-update-success', (event) => {
console.log('Task updated:', event.detail);
});For a complete list of configuration options, please refer to the ApexGantt documentation.
- Node.js (v20 or higher recommended)
- npm or yarn
# Clone the repository
git clone https://github.com/apexcharts/apexgantt-webcomponent.git
# Install dependencies
npm install
# Start development server
npm start
# Run tests
npm test
# Build for production
npm run buildnpm start- Start development server with live reloadnpm run build- Build for productionnpm test- Run test suitenpm run test:watch- Run tests in watch modenpm run lint- Lint codenpm run fix- Fix linting issues
This component works in all modern browsers that support:
- Custom Elements (Web Components)
- ES Modules
- ES2020 features
For older browsers, you may need polyfills.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
If you encounter any issues or have questions, please open an issue on GitHub.