@uzbeki/jquery-gantt-chart
v1.0.0
Published
Simple Gantt Chart implemented with modernJS and jQuery. Previously known as jQuery.Gantt.
Downloads
33
Maintainers
Readme
Demo and Documentation
This is a fork of the original jquery-gantt. It was not maintained for a long time and I decided to fork it and make it work with modern browsers and jQuery versions. I also added some new features and fixed some bugs.
- Live Demo: https://uzbeki.github.io/jquery-gantt-chart/
- Repository: https://github.com/uzbeki/jquery-gantt-chart
- NPM page: https://www.npmjs.com/package/@uzbeki/jquery-gantt-chart
- Github package: https://github.com/uzbeki/jquery-gantt-chart/pkgs/npm/jquery-gantt-chart
Installation
- Git clone
yarn add @uzbeki/jquery-gantt-chart
, ornpm install @uzbeki/jquery-gantt-chart
About
jQuery Gantt Chart is a modern and fast plugin that implements gantt functionality as a jQuery component with JS Module support.
Plugin was tested and should work on: All major browsers that support ES6 or above.
Features:
- 📟 Pagination support, page data handler set inside
onGetPage
option - 👉 Customizable cell size with
cellSize
option - 🎨 Customizable task(bar) colors with
data[i].values[j].customClass
- 🏷️ Display short description as hints
- 🖱️ Scroll with
Shift+mouseWheel
, or faster scroll withCtrl+Shift+mouseWheel
- 📅 Mark holidays or today
- 🔍 Zoom in/out
- Drag Sortable Header Support
- 🆕 ES Module support
- 🆕 Remember Zoom Level and Header Order (page by page remembering)
- 🆕 Resizable Bars from both left and righ ends with
barOptions.resizability
options - 🆕 Movable Bars (vertial and horizontal support) with
barOptions.movability
options - 🆕 Easy to sort bars to align them one after the another
Requirements:
- jQuery v1.10.2 or above:
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
Usage
Simply include the plugin and its stylesheet in your html file and call it on a div element.
<link rel="stylesheet" href="./src/jquery.gantt.css">
<script type="module" src="./src/index.js"></script>
Create a div element and call the plugin on it
<script type="module">
$("#gantt").gantt({
source: data, // json data
scale: "days",
onItemClick: console.log,
onAddClick: console.log,
onRender: () => console.log("chart rendered"),
onGetPage: (page) => yourPageHandler(page),
});
</script>
Customizable Options
source
- json data, defaults to{}
navigate
- navigation type (buttons, scroll), defaults toscroll
scrollToToday
- scroll to today, defaults totrue
zoomLevelKey
- key to save zoom level, defaults tojquery-gantt-chart-zoom-level
rememberZoomLevel
- remember current zoom level, defaults totrue
rememberHeaderOrder
- remember header order, defaults totrue
scale
- scale type (hours, days, weeks, months), defaults todays
maxScale
- maximum scale, defaults tomonths
minScale
- minimum scale, defaults tohours
cellSize
- cell size in pixels, defaults to24
holidays
- array of holidays, defaults to[]
itemsPerPage
- items per page, defaults to10
dow
- days of week, defaults to["S", "M", "T", "W", "T", "F", "S"]
months
- months, defaults to["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
barOptions
- bar options, defaults to DefaultBarOptionsresizability
- bar resizability, defaults to DefaultBarOptions.resizabilitymovability
- bar movability, defaults to DefaultBarOptions.movability
onItemClick
- callback on item click, called with item objectonAddClick
- callback on add button click, called with date and row dataonRender
- callback on chart renderonGetPage
- callback on page change, called with page number
source
is an object of the following type
type SourceData = {
data: Array<{
id: number;
name: string;
desc: string;
values: Array<{
from: Date;
to: Date;
label: string;
desc: string;
customClass: string; // for coloring bars
}>;
}>;
// pagination
currentPage: number;
pageCount: number;
itemsPerPage: number;
};
DefaultBarOptions
const DefaultBarOptions = {
resizability: {
minWidth: DEFAULT_CELL_SIZE, // 24
maxWidth: Infinity, // maximum width
onResize: newWidth => {}, // callback on resize
stepSize: DEFAULT_CELL_SIZE, // 24
handleVisibility: "hover", // "hover" | "click" | "always"
leftHandle: false, // show left handle to resize
rightHandle: true, // show right handle to resize
},
movability: {
stepSize: DEFAULT_CELL_SIZE, // 24
horizontal: true, // allow horizontal movement
vertical: false, // allow vertical movement
minX: 0, // minimum x position
minY: 0, // minimum y position
maxX: Number.POSITIVE_INFINITY, // maximum x position
maxY: Number.POSITIVE_INFINITY, // maximum y position
};
};
License
MIT