Giter VIP home page Giter VIP logo

gantt's Introduction

Gantt Chart

Gantt chart library using jsx support SVG, Canvas and SSR

NPM version NPM downloads Greenkeeper badge

Install

$ npm install gantt --save

Usage

View demo online

import { SVGGantt, CanvasGantt, StrGantt } from 'gantt';

const data = [{
  id: 1,
  type: 'group',
  text: '1 Waterfall model',
  start: new Date('2018-10-10T09:24:24.319Z'),
  end: new Date('2018-12-12T09:32:51.245Z'),
  percent: 0.71,
  links: []
}, {
  id: 11,
  parent: 1,
  text: '1.1 Requirements',
  start: new Date('2018-10-21T09:24:24.319Z'),
  end: new Date('2018-11-22T01:01:08.938Z'),
  percent: 0.29,
  links: [{
    target: 12,
    type: 'FS'
  }]
}, {
  id: 12,
  parent: 1,
  text: '1.2 Design',
  start: new Date('2018-11-05T09:24:24.319Z'),
  end: new Date('2018-12-12T09:32:51.245Z'),
  percent: 0.78,
}];

new SVGGantt('#svg-root', data, {
  viewMode: 'week'
});

new CanvasGantt('#canvas-root', data, {
  viewMode: 'week'
});

const strGantt = new StrGantt(data, {
  viewMode: 'week'
});
this.body = strGantt.render();

image

API

interface Link {
  target: number,
  type: 'FS' | 'FF' | 'SS' | 'SF'
}

interface Item {
  id: number,
  parent: number,
  text: string,
  start: Date,
  end: Date,
  percent: number,
  links: Array<Link>
}

type StyleOptions = {
  bgColor: string,           // default: '#fff'
  lineColor: string,         // default: '#eee'
  redLineColor: string,      // default: '#f04134'
  groupBack: string,         // default: '#3db9d3'
  groupFront: string,        // default: '#299cb4'
  taskBack: string,          // default: '#65c16f'
  taskFront: string,         // default: '#46ad51'
  milestone: string,         // default: '#d33daf'
  warning: string,           // default: '#faad14'
  danger: string,            // default: '#f5222d'
  link: string,              // default: '#ffa011'
  textColor: string,         // default: '#222'
  lightTextColor: string,    // default: '#999'
  lineWidth: string,         // default: '1px'
  thickLineWidth: string,    // default: '1.4px'
  fontSize: string,          // default: '14px'
  smallFontSize: string,     // default: '12px'
  fontFamily: string,        // default: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
}

type Options = {
  viewMode: 'day' | 'week' | 'month',
  onClick: (item: Item) => {},
  offsetY: number,               // default: 60,
  rowHeight: number,             // default: 40,
  barHeight: number,             // default: 16,
  thickWidth: number,            // default: 1.4,
  styleOptions: StyleOptions
}

declare class SVGGantt {
  constructor(element: string | HTMLElement, data: Array<Item>, options: Options);
  setData(data: Array<Item>): void;      // set data and re-render
  setOptions(options: Options): void;    // set options and re-render
  render(): void;
}

declare class CanvasGantt {
  constructor(element: string | HTMLElement, data: Array<Item>, options: Options);
  setData(data: Array<Item>): void;      // set data and re-render
  setOptions(options: Options): void;    // set options and re-render
  render(): void;
}

declare class StrGantt {
  constructor(data: Array<Item>, options: Options);
  setData(data: Array<Item>): void;
  setOptions(options: Options): void;
  render(): string;
}

Report a issue

License

Gantt is available under the terms of the MIT License.

gantt's People

Contributors

greenkeeper[bot] avatar helloyou2012 avatar nickicindy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gantt's Issues

Responsive

is it possible to adapt size to the size of the parent element? and also get a sticky on the first column

[Question] How to using this app

Hello sir, I know it is kinda a weird question, I have no idea with JSX, is it a ract app?
I just clone this repo, and run index.html as usual, but there is an error, the error said that bundle.js is not found, and of course bundle.js is not found, I don't know how to use this, can you give me some explanation to install this app?

Example data in readme is missing `links: []`

links: [] is missing from the last item of the example data in README.md. Without it you get the following error:

“Uncaught TypeError: Cannot read property 'map' of undefined”

.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

Changelog/Release notes

The version I'm using right now is 3.0.12 and I though about upgrading to 3.1 but I'm not sure if something might break. Following SemVer, maybe there are new features and nothing should break, but I wanted to be sure.

The width of SVG can not be write in Safari browser

Hi,
I use this.gantt = new SVGGantt('#svgAccount', this.top10, this.ganttOptions); to draw gatt, it works well in Chrome and firefox, but not in Safari.

The error is :

Error: Invalid value for attribute width="NaN"
Error: Invalid value for attribute width="NaN"
Error: Invalid value for attribute x2="NaN"
Error: Invalid value for attribute x1="NaN"

I think this is an issue for Safari.
Is there a way to set the width of the svg and the rest elements' with under svg?
Thanks very much!

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

Internationalization

Is there any plans to support internationalization or an option to set the date formats and the months names? Can I contribute with some ideas to implement something?

Fix the width of the chart

Is there any way to fix the with of the chart - ideally responsive, but at the very least fixed width.

style tags seem to be ignored, and the options seem not to have a width

How to get it to work?

Hello,

I've placed index.html from the demo folder in a server folder, downloaded the gantt.js and added it

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

in the header tag. Then I've copied the sample code from the Usage doc but it doesn't find the SVGGantt class.

How do I get it to work?

Freeze left side text column and scroll taskbars

Hi, thanks for nice library!
I do have a question: is it somehow possible to make the task bars scrollable and the left text column frozen. So the task descriptions (text) will always be visible and the taskbars can be scrolled underneath.
Thanks

Inline tasks

Is there a way to draw two or more tasks (or milestones) each line?

how to use at react?

export const Gantt = () => {
return

{strGantt.render()}
;
};

this useage methods page will show the element string

Issue with Angular 14

Compiled successfully.
./node_modules/gantt/es/render/svg.js:4
var doc = document;
^

ReferenceError: document is not defined
at Module.69889 (./node_modules/gantt/es/render/svg.js:4:11)
at webpack_require (./webpack/bootstrap:19:1)
at Module.27024 (./node_modules/gantt/es/CanvasGantt.js:95:4)
at webpack_require (./webpack/bootstrap:19:1)
at Module.84332 (./node_modules/gantt/es/h.js:41:1)
at webpack_require (./webpack/bootstrap:19:1)
at Module.8720 (./src/app/views/pages/builder/project/component.html:316:49)
at webpack_require (./webpack/bootstrap:19:1)
at Module.74570 (./src/app/views/pages/builder/builder.component.html:1:32)
at webpack_require (./webpack/bootstrap:19:1)

Node.js v20.6.1

A server error has occurred.
node exited with 1 code.

"Hours" view mode

Hi,
Would it be possible to add a mode "Hours". Or slots of 2 hours?
This would help me a lot.
Greetings, Sara

Demo should not obfuscate js functions

Without any formal documentation, we are relying on the demo to understand how some of the functions work (e.g. changing the view mode). However, the library and functions are obfuscated in bundle.js, adding additional complexity to understand how this library work. It would be good to unobfuscate the library so that more people can understand how this library works.

Anyway, for those looking to change the view mode, it will be:

  1. Setting the object.options.viewMode to 'day' / 'week' / 'month'
  2. Invoke object.render();

where object is the variable assigned when initializing the gantt chart.

Thank you.

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.