npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ibm-gantt-chart

v0.5.33

Published

IBM Gantt Chart Component, integrable in Vanilla, jQuery, or React Framework.

Downloads

2,045

Readme

ibm-gantt-chart

Usage

Here is a simple example to illustrate how to include the Gantt into a web page.

<html>
  <head>
    <title>Simple Gantt</title>
    <link href="[...]/ibm-gantt-chart.css" rel="stylesheet" />
    <script src="[...]/ibm-gantt-chart.js"></script>

    <!--  Page styles  -->
    <style>
      html {
        height: 100%;
      }
      body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
      #gantt {
        height: 100%;
      }
    </style>
  </head>
  <body>
    <div id="gantt"></div>

    <script>
      var data = [
        {
          id: 'NURSES+Anne',
          name: 'Anne',
          activities: [
            {
              id: 'SHIFTS+Emergency+Monday+2+8',
              name: 'Emergency',
              start: 1474880400000,
              end: 1474902000000,
            },
          ],
        },
        {
          id: 'NURSES+Bethanie',
          name: 'Bethanie',
          activities: [],
        },
        {
          id: 'NURSES+Betsy',
          name: 'Betsy',
          activities: [
            {
              id: 'SHIFTS+Emergency+Wednesday+12+18',
              name: 'Emergency',
              start: 1475089200000,
              end: 1475110800000,
            },
            {
              id: 'SHIFTS+Emergency+Saturday+12+20',
              name: 'Emergency',
              start: 1475348400000,
              end: 1475377200000,
            },
            {
              id: 'SHIFTS+Consultation+Friday+8+12',
              name: 'Consultation',
              start: 1475247600000,
              end: 1475262000000,
            },
          ],
        },
        {
          id: 'NURSES+Cathy',
          name: 'Cathy',
          activities: [
            {
              id: 'SHIFTS+Emergency+Sunday+20+2',
              name: 'Emergency',
              start: 1475463600000,
              end: 1475485200000,
            },
            {
              id: 'SHIFTS+Emergency+Saturday+12+20',
              name: 'Emergency',
              start: 1475348400000,
              end: 1475377200000,
            },
            {
              id: 'SHIFTS+Emergency+Monday+18+2',
              name: 'Emergency',
              start: 1474938000000,
              end: 1474966800000,
            },
          ],
        },
        {
          id: 'NURSES+Cindy',
          name: 'Cindy',
          activities: [
            {
              id: 'SHIFTS+Emergency+Saturday+20+2',
              name: 'Emergency',
              start: 1475377200000,
              end: 1475398800000,
            },
            {
              id: 'SHIFTS+Consultation+Friday+8+12',
              name: 'Consultation',
              start: 1475247600000,
              end: 1475262000000,
            },
            {
              id: 'SHIFTS+Consultation+Tuesday+8+12',
              name: 'Consultation',
              start: 1474988400000,
              end: 1475002800000,
            },
          ],
        },
      ];
      var config = {
        data: {
          // Configures how to fetch resources for the Gantt
          resources: {
            data: data, // resources are provided in an array. Instead, we could configure a request to the server.
            // Activities of the resources are provided along with the 'activities' property of resource objects.
            // Alternatively, they could be listed from the 'data.activities' configuration.
            activities: 'activities',
            name: 'name', // The name of the resource is provided with the name property of the resource object.
            id: 'id', // The id of the resource is provided with the id property of the resource object.
          },
          // Configures how to fetch activities for the Gantt
          // As activities are provided along with the resources, this section only describes how to create
          // activity Gantt properties from the activity model objects.
          activities: {
            start: 'start', // The start of the activity is provided with the start property of the model object
            end: 'end', // The end of the activity is provided with the end property of the model object
            name: 'name', // The name of the activity is provided with the name property of the model object
          },
        },
        // Configure a toolbar associated with the Gantt
        toolbar: [
          'title',
          'search',
          'separator',
          {
            type: 'button',
            text: 'Refresh',
            fontIcon: 'fa fa-refresh fa-lg',
            onclick: function(ctx) {
              ctx.gantt.draw();
            },
          },
          'fitToContent',
          'zoomIn',
          'zoomOut',
        ],
        title: 'Simple Gantt', // Title for the Gantt to be displayed in the toolbar
      };
      new Gantt('gantt' /* the id of the DOM element to contain the Gantt chart */, config);
    </script>
  </body>
</html>

Including this Gantt chart into a Web page consists on:

  • Including the Gantt library bundle files, one Javascript and one CSS file.
  • Create DOM element that will contain the Gantt chart. This is done here with the declaration:
    <div id="gantt"></div>
  • Create a Javascript object to configure the Gantt.
  • Instantiate the Gantt chart object with this configuration object and the id of the DOM element to contain the Gantt chart. As explained below, the Gantt library is packaged for several frameworks (jQuery, React or as a pure Javascript component). Use the one that fits the need of your page. For this example, the Vanilla Javascript component is used.

Data

In the first example, data is provided to the Gantt as an array of resources created on the client side to get a self contained example. The Gantt can also be configured to fetch data from a server and map this data into a Gantt model. The example Activity chart shows how customizable the process of fetching user data and mapping it to a Gantt model can be.

Formatting, filtering and other features

The Gantt library is rich of features for formatting and navigating into user data. The Gantt examples illustrate how to configure and use these features.

Gantt packages

The simple Gantt chart example uses the Gantt chart as a Vanilla Javascript component. The Gantt library also distributes the Gantt as a React component and a jQuery component. For those packages, the configuration of the Gantt is done using the same configuration object. Only the bundle files to include and the how the Gantt object is constructed differ.

  1. The Gantt as a React component

    import React from 'react';
    import ReactDOM from 'react-dom';
    import GanttChart from 'ibm-gantt-chart-react';
    
    import 'ibm-gantt-chart/dist/ibm-gantt-chart.css';
    
    const config = { ... }; // Same format as in the simple Gantt example.
    
    ReactDOM.render(<GanttChart config={config} />, document.getElementById('gantt'));
  1. The Gantt as a jQuery component

    <html>
      <head>
        <!-- Datatables.net CSS file -->
        <!-- See  https://datatables.net/download/index -->
        <link href="[...]/datatables.net-dt/css/jquery.dataTables.css" rel="stylesheet" />
    
        <!-- vis CSS file -->
        <!-- See  http://visjs.org/#download_install -->
        <link href="[...]/vis/dist/vis.min.css" rel="stylesheet" type="text/css" />
    
        <!-- Gantt CSS file -->
        <link href="[...]/dist/css/gantt-jquery.css" rel="stylesheet" type="text/css" />
      </head>
      <body>
        ...
        <!-- DOM node to contain the Gantt component. -->
        <div id="gantt"></div>
        ...
        <!-- Include jQuery, see https://jquery.com/download/ -->
        <script src="[...]/jquery/dist/jquery.min.js"></script>
    
        <!-- Datatables.net JS file -->
        <!-- See  https://datatables.net/download/index -->
        <script src="[...]/datatables.net/js/jquery.dataTables.js"></script>
    
        <!-- vis JS file -->
        <!-- See  http://visjs.org/#download_install -->
        <script src="[...]/dist/vis.min.js"></script>
    
        <!-- Gantt JS bundle file -->
        <script src="[...]/ibm-gantt-chart-jquery.js"></script>
        <script>
          var config = { ... }; // Same format as for the simple Gantt example
          $(document).ready(function() {
              $('#gantt').Gantt(config);
          } );
        </script>
      </body>
    </html>