Creating a Gantt Chart with jsgantt-improved: A Step-by-Step Guide

Jun 11, 2022 | Programming

Unleash the power of project visualization with a fully featured Gantt chart component developed in pure JavaScript, CSS, and AJAX. The jsgantt-improved library is lightweight, easy to use, and does not require any external libraries or additional images.

Getting Started

There are two primary ways to include jsgantt-improved in your project. You can either include it directly by referencing the files or install it via npm. Here’s how to get started:

  • **Including Files:**
    Simply include jsgantt.js and jsgantt.css from the dist folder in your HTML.
  • **Or Install via NPM:**
    Run the command npm install jsgantt-improved in your terminal.

Implementation Steps

Follow these steps to get your Gantt chart up and running:

<link href="jsgantt.css" rel="stylesheet" type="text/css">
<script src="jsgantt.js" type="text/javascript"></script>
<div style="position:relative;" class="gantt" id="GanttChartDIV"></div>
<script>
  var g = new JSGantt.GanttChart(document.getElementById("GanttChartDIV"), "day");
  g.setOptions({
    vCaptionType: "Complete",
    vQuarterColWidth: 36,
    vDateTaskDisplayFormat: "day dd month yyyy",
    vDayMajorDateDisplayFormat: "mon yyyy - Week ww",
    vWeekMinorDateDisplayFormat: "dd mon",
    vLang: "en",
    vShowTaskInfoLink: 1,
    vShowEndWeekDate: 0,
    vAdditionalHeaders: [],
    vUseSingleCell: 10000,
    vFormatArr: ["Day", "Week", "Month", "Quarter"]
  });
  // Load from a JSON URL
  JSGantt.parseJSON("fixesdata.json", g);
  g.Draw();
</script>

This code snippet is akin to setting up a stage for a grand performance. The GanttChart function prepares the chart with all necessary options, like a director giving instructions for a play, such as how scenes should be set and displayed. Then the tasks are loaded either through JSON (as if actors are showing up for their roles) or added manually.

Features of jsgantt-improved

Utilizing jsgantt-improved enables a variety of functionalities:

  • Collapsible task groups
  • Task dependencies with highlights on hover
  • Task completion tracking
  • Dynamic loading of tasks
  • Support for multiple languages

Troubleshooting

If you encounter issues while implementing jsgantt-improved, here are some troubleshooting steps to consider:

  • Ensure that the paths to jsgantt.js and jsgantt.css are correct.
  • Double-check the syntax used in your HTML and JavaScript code.
  • If the Gantt chart is not displaying as expected, verify that all tasks are correctly formatted in your JSON format.
  • Use browser developer tools to check for any error messages in the console.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox