GithubHelp home page GithubHelp logo

gustcortarelli / gc-gantt Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 16 KB

A pure JS Gantt chart

CSS 9.80% JavaScript 76.22% HTML 13.98%
gantt gantt-chart javascript-library purejs open-source free

gc-gantt's Introduction

gc-gantt

A pure open source JS Gantt's chart.

The porpouse of this LIB is create a gannt chart using only Javascript, without any other framework.

How to use? (basic usage)

Add on your page the CSS script:

<link href="css/gcGantt.css" media="all" rel="stylesheet" type="text/css" />

You should make your won style if you want.

and also the JS script:

<script src="js/gcGantt.js" type="text/javascript"></script>

after all, you should config your HTML, creating a div wich will be used to render a gantt chart:

<div id="gc-gantt"></div>

and now, we build our tasks object:

var jsonData = [{
     "id": 1,
     "description": "group tasks 1",
     "start": "2016-12-01",
     "end": "2016-12-15",
     "calculatePercent": true,
     "color": "#004d00",
     "tasks": [
        {
           "id": 2,
           "description": "group tasks 2",
           "start": "2016-12-03",
           "end": "2016-12-10",
           "calculatePercent": true,
           "tasks": [{
                 "id": 1,
                 "description": "Task 1",
                 "start": "2016-12-03",
                 "end": "2016-12-07",
                 "resources": ["person A", "person B"],
                 "percent": 50
              }
           ],
        }
     ]
  }
];

finally, make a configuration in order to build a gantt with some tasks, you must parse the element ID where the gantt's chart will be render, the task object and config object:

var gcGantt = new GCGantt('gc-gantt', jsonData, {});

Events

This lib is able to control click on events and, until now, two kinds of functions are available:

On task name click

gcGantt.onTaskNameClick = function (id, group) {
  if (group) {
     alert("Clicked on name of group name ID: " + id);
  } else {
     alert("Clicked on name of task name ID: " + id);
  }
}

On task click

gcGantt.onTaskClick = function (id, group) {
  if (group) {
     alert("Clicked on group ID: " + id);
  } else {
     alert("Clicked on task ID: " + id);
  }
}

Options

You can change some stuffs into gantt parsing some configurations on config object:

var _config = {
      showResources: true, //boolean - show/hide column resource
      showStartDate: true, //boolean - show/hide column date start
      showEndDate: true, //boolean - show/hide column date end
      title: { //change column titles
         task: "Task name", // column task title
         start: "Start", // column date start title
         end: "End", // column date end title
         resources: "Resources", // column resource titlte
         percent: "Percent (%)" // column percent title
      }
   };

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.