Coder Social home page Coder Social logo

ibm / gantt-chart Goto Github PK

View Code? Open in Web Editor NEW
211.0 15.0 52.0 9.38 MB

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

Home Page: https://ibm.github.io/gantt-chart/packages/ibm-gantt-chart-docs/storybook

License: Apache License 2.0

JavaScript 83.95% HTML 4.48% CSS 4.57% SCSS 7.00%

gantt-chart's Introduction

@ibm/gantt-chart

npm GitHub

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

Getting started

Documentation and Examples are available as a storybook

This project is structured as a monorepo:

Package Description
ibm-gantt-chart Gantt Chart Library
ibm-gantt-chart-dev Development Environment for Gantt Chart Library
ibm-gantt-chart-docs Documentation and examples
ibm-gantt-chart-react The Gantt Chart React Component

Contributing

Check out the Contributing Guide.

Contributors ✨

Thanks goes to these wonderful people (emoji key), especially Olivier Noiret, creator of the initial project:

Olivier Noiret
Olivier Noiret

💻 📖 💡 📦
Gilles d'Andréa
Gilles d'Andréa

💻 📖 💡 📦

This project follows the all-contributors specification. Contributions of any kind welcome!!

License

Licensed under the Apache 2.0 License.

gantt-chart's People

Contributors

ali-sadeghin avatar aravindha1234u avatar delhoume avatar gillesdandrea avatar jamieslome avatar johnkraczek avatar sartoshi-foot-dao avatar stevemart 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  avatar

gantt-chart's Issues

Next.js support

Hello,
I'm trying to use ibm-gantt-chart-react with next.js, but I'm getting an error "window is not defined". Is there anything I should set differently when using next.js? (maybe it's trying to render the chart on the server?)

Question: Show tooltip on click

Hi,

I need to change the behavior of the gantt chart, so that tooltip would show up on click. Is it possible to achieve somehow? Or will I have to alter the code of the plugin?

Thanks in advance!

How to generate vanilla bundles (no jQuery or React)?

I am trying to use IBM-gantt-chart in Anvil (see Anvil.works). I have successfully generated bundle files by running 'npm run build'. I can see that jQuery has been included in the js file. My issue is that the Anvil platform documentation states -'it is a bad idea to load jQuery or Bootstrap Javascript explicitly from an HTML template — it will overwrite the versions Anvil has already loaded.'. The IBM-Gantt documentation suggests that it should be possible to produce a 'vanilla' bundle file which does not include jQuery but I can't find any documentation on how to do this, nor can I work out how to do it from looking at the code (I am new to JavaScript). Any pointers would be gratefully received. Thanks

Local/C: reference in vis.js:34455:10

Hello,
I have a "unsupported protocol for sourcemap request webpack://ibm-gantt-chart/C:/Users/yotamberk/Desktop/workspace/vis/dist/vis.js" message when loading the tool with a CSP.
Ref : vis.js:34455:10.

What Vis-components to use when using as Jquery component

Docs says vis css and js file, but there are five different components to choose from.

<!-- vis CSS file --> <!-- See http://visjs.org/#download_install --> <link href="[...]/vis/dist/vis.min.css" rel="stylesheet" type="text/css" />

<!-- vis JS file --> <!-- See http://visjs.org/#download_install --> <script src="[...]/dist/vis.min.js"></script>

The supplied link does not work.

How to initiate gantt chart declarative way?

I have personal project to practice my js skill. I found this repo and i'm interested to give a try.
I want to make a component that contain gantt chart. I tried this code below. But it was rendered and duplicated.

const ganttchart=(props)=>{    
    const data = [
        {
          id: 'NURSES+Anne', name: 'Anne',
          activities: [
              {
              id: 'SHIFTS+Emergency+Monday+2+8',
              name: 'Emergency',
              start: 1474880400000,
              end: 1474902000000,
              },
          ],
        },
    ];
    const config = {
        data: {
          resources: {
              data: data, 
              activities: 'activities',
              name: 'name', 
              id: 'id',
          },
          activities: {
              start: 'start',   end: 'end',    name: 'name', 
          },
        },
        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',  
    };
    setTimeout(() => {
      new Gantt('gantt', config); // eslint-disable-line no-new
    }, 0);
    return (<div id="gantt" style={{minHeight:'400px !important'}}></div>)
}
export default ganttchart;

I also tried with declarative way like the code below

const ganttchart=(props)=>{    
    const data = [
        {
          id: 'NURSES+Anne',
          name: 'Anne',
          activities: [
              {
              id: 'SHIFTS+Emergency+Monday+2+8',
              name: 'Emergency',
              start: 1474880400000,
              end: 1474902000000,
              },
          ],
        },
    ];
    const config = {
        data: {
        //....
        },
        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',  
    };
  return (<GanttChart config={config} />);
}
export default ganttchart;

I use both ways inside a parent component like this :

function parentComponent{
  return(
        <div>
           <GanttChart detailProject={data} />      
        </div>
  )
}                         

When i use the first one, gantt chart was successfuly rendered but it duplicates several times

here is the result :
image

When i use the second one, gantt chart was not rendered and threw an error
image

parent in activity model needs to be explicitly set

The parent property needs to be set in the model, i.e.:

activities: {
    data: [],
    parent: 'parent'
}

for the activity data parent property to be honored, otherwise activites are not grouped in the component.

dateFormat must define all six date components or NaN is returned

A date format expressed like:

data: {
    dateFormat : "yyyy-MM-dd HH:mm"

Doesn't assign a value to fmt[secs] in Gantt.utils.createDateParser(format), which results in undefined when passed in:

return new Date(
parts[fmt[year]],
parts[fmt[month]] - 1,
parts[fmt[day]],
parts[fmt[hour]],
parts[fmt[min]],
parts[fmt[secs]]
).getTime();
};

resulting in a NaN value, but without any error thrown.

All properties should accept a function and return null should be interpreted as use the default if possible.

As an example of what i think should be good to have, i will provide the next timeTable definition:

timeTable: {
    renderer: [
        {
            selector: function(object, ctx) {
                return ctx.gantt.displayMode === 'showTasks';
            },
            text: function(activity, ctx) {
                var textRef = config["displayModes"][ctx.gantt.displayMode]["text"];
                return getData(activity, textRef);
            },
            textOverflow: 'noDisplay',
            background: {
                palette: function(activity, ctx) {
                    return ['#5aa8f8', '#4178bc', '#8cd211', '#c8f08f', '#ba8ff7', '#a6266e', '#ff7832'];
                },
                getValue: function(activity, ctx) {
                    var textRef = config["displayModes"][ctx.gantt.displayMode]["text"];
                    return getData(activity, textRef);
                },
            },
        },
    ]
}

In the example, return null for a palette should be interpreted as "use the default palette" instead of display an error, because this allow us to decide dynamically to use the default palette. We have not way to said "use the default palette" from a function right now.

palette: function(activity, ctx) {
    return null
},

Also for compatibility reasons the next definition should be interpreted also as "use the default palette":

palette: null

The next definition should be good to be accepted as a valid one, but right now is not working:

background: function(activity, ctx) {
    return {
        palette: function(activity, ctx) {
            return ['#5aa8f8', '#4178bc', '#8cd211', '#c8f08f', '#ba8ff7', '#a6266e', '#ff7832'];
        },
        getValue: function(activity, ctx) {
            var textRef = config["displayModes"][ctx.gantt.displayMode]["text"];
            return getData(activity, textRef);
        },
    },
},

Allow that background can be a function can simplify in some cases the code.

Problem with the React peer dependency in the latest CRA template

Hi, I am attempting to evaluate this component in an application based on Create React App. The CRA template I have used is recent, and it uses React 18. It seems the React peer dependency of ibm-gantt-chart-react is hardcoded to 16.8.6:

https://github.com/IBM/gantt-chart/blob/master/packages/ibm-gantt-chart-react/package.json#L42

When trying to install the component using npm i ibm-gantt-chart-react, NPM throws this error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"16.8.6" from [email protected]
npm ERR! node_modules/ibm-gantt-chart-react
npm ERR! ibm-gantt-chart-react@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or U
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

This error will likely happen to anyone using latest React, regardless of whether they are using CRA or not.

Using npm i ibm-gantt-chart-react --legacy-peer-deps works, because to my knowledge there are no breaking changes between 16.8.6 and 18.0.0 that would prevent this component from working.

I think you could solve this issue by not hardcoding a React version in the peer dependency, but instead making it a range that accepts anything between 16.8.6 and 18. See these links:

Hope this helps.

Modernize code JS+SCSS

Code still contains legacies that breaks linting. Here is the list of disabled rules that should be handled, see .eslintrc.js

  • class-methods-use-this
  • consistent-return
  • func-names // brute force to replace /function() {/() => {/ breaks tests
  • new-cap
  • no-cond-assign
  • no-console
  • no-continue
  • no-extend-native
  • no-multi-assign
  • no-mixed-operators
  • no-nested-ternary
  • no-param-reassign
  • no-plusplus
  • no-shadow
  • no-restricted-globals
  • no-restricted-syntax
  • no-throw-literal
  • no-undef
  • no-underscore-dangle
  • no-unused-expressions
  • no-unused-vars
  • no-use-before-define
  • no-useless-constructor
  • no-var // brute force replacement /var/let/ breaks tests
  • one-var
  • prefer-destructuring
  • prefer-promise-reject-errors
  • prefer-rest-params
  • prefer-spread
  • prefer-template
  • vars-on-top

And stylelint too:

  • no-descending-specificity

Drag-n-Drop to other row

Fist, great component! Tks for opensource it. Second, Javascript is not my core lang so I'm kind of a bit lost.

Anyway, trying to use this in a Blazor (WebAssembly) project and facing a problem. When drag'n droping to another row the activity does not "flow" to that row and tooltip not working and further drag... to that activity are no longer possible.

Thanks.

Localization

Hello, is it possible to specify a localization/translation for application strings?

How to translate timeline date into japanese ?

Can someone give me an example to change timeline language to japanese ?

I found this setTimeWindow function at ibm-gantt-chart/jquery/timeline.js that can do this but I haven't figured out how to configure it. Please help me !!

Question: How to custom filter

Hi, I'd like to add some additional filtering options to the gantt chart, but the docs aren't clear how to go about that. I tried adding filter : function(object, ctx, search ){} within the renderer object like the docs mention in Miscellaneous/Renderers, but the function isn't triggered (I put a console.log inside it to see if it was being called). None of the examples use it so I don't know exactly what is expected. Any insight would be appreciated, thank you.

Clickable entry with link

Hello, the plugin as really nice, but there is one important feature which I cannot set:

We need to make the entries clickable, so when we click an entry it opens a link with a parameter specific to the entry. I want to add the parameter somewhere in the HTML attribute of the entry so a click listener can pick it up from there.

I was unable to do this so far, is there any solution I am missing?

image

Best Regards
Martin Nekula

Accessibility issue with empty Gantt

With the IBM Equal Access Accessibility checker, you'll get this error:
Complex table does not have headers for each cell properly defined with 'header' or 'scope'

explicit start and end properties in static timewindow data result in error

While this:

timeWindow : {
    data: {
          start : 1667257200000,
          end : 1668466800000,
    },
  },

works and centers the component view between 1 and 15 of november, explicitly defining the start and end properties:

timeWindow : {
    data: {
          start : 1667257200000,
          end : 1668466800000,
    },
    start: 'start',
    end: 'end'
  },

results in error:

Uncaught (in promise) Error: Could not configure data for timeWindow. Probably a configuration issue with key(s) start,end

processClick : how do i get id of any activity

toolbar: [
'title',
'search',
'separator',
{
type: 'button',
text: 'Refresh',
fontIcon: 'fa fa-refresh fa-lg',
onclick: function (ctx) {
ctx.gantt.draw();
},
},
'fitToContent',
'zoomIn',
'zoomOut',
// User specific toolbar components
],
title: 'Proje Zaman Çizelgesi', // Title for the Gantt to be displayed in the toolbar
timeTable: {
renderer: [
{
selector: function (object, ctx) {
// Use this renderer if the display mode combobox is selected on 'Tasks'
//console.log(object["id"]);
//return ctx.gantt.colorMode === 'showTasks'
},
text: function (activity) { // Instead of using a function, the text property could have been declared as: text : "TASK.NAME"
return activity.TASK.NAME
},
textOverflow: 'noDisplay', // Hide the text if it doesn't fit the width of the activity rectangle
background: {
// Uncomment line below to fix the index order of task names and therefore ensure tasks will always be displayed with the same color.
//values : [ 'facade', 'ceiling', 'windows', 'moving', 'masonry', 'carpentry', 'roofing', 'plumbing', 'painting', 'garden' ],
// Uncomment line below for using a palette replacement from the default Gantt palette.
palette: ["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c", "#fb9a99", "#e31a1c", "#fdbf6f", "#ff7f00", "#cab2d6", "#6a3d9a"],
getValue: 'TASK.NAME'
},
color: 'automatic', // Text color will be white or black depending on the background color of the activity rectangle.
tooltipProperties: function (activity, ctx) {
var props = ['Start', new Date(activity.start).format(), 'End', new Date(activity.end).format()];
// Create a large amount of tooltip properties to demonstrate how the tooltip behaves on large property numbers.
for (var i = 0; i < 50; i++) {
props.push('Property ' + (i + 1));
props.push('Value ' + (i + 1));
}
return props;
}
}, {
selector: function (object, ctx) {
// Use this renderer if the display mode combobox is selected on 'Houses'
//alert(object["id"]);
//return ctx.gantt.colorMode === 'showHouses'
},
text: function (activity) {
return "H" + activity.HOUSE;
},
background: {
values: function (object, ctx) {
return Object.keys(ctx.gantt.houseTimeWindows);
},
// Default palette is used
getValue: 'HOUSE' // Access the HOUSE field of provided activity. eq to function(act) { return act.HOUSE; }
},
color: 'automatic' // Text color will be white or black depending on the background color of the activity rectangle.
}, {
selector: function (object, ctx) {
// Use this renderer if the display mode combobox is selected on 'All'
//alert(object["id"]);
//console.log(object["id"]);
//return ctx.gantt.colorMode === 'showAll'
},

                                    text: function (activity) {
                                        return "H" + activity.HOUSE + '-' + activity.TASK.NAME;
                                    },
                                    background: {
                                        values: function (object, row) {
                                            return Object.keys(row.gantt.houseTimeWindows);
                                        },
                                        getValue: 'HOUSE'
                                    },
                                    color: 'automatic' // Text color will be white or black depending on the background color of the activity rectangle.


                                },

                            ],
                            interactor: {
                                click : {
                                    processClick(p){
                                        console.log("asdsad");
                                    }
                                }
                            },

                        }

TimeWindow in Config - can't configure

Hello,

I am trying to configure TimeWindow property to my Gantt, but I can't get this working...

Using this code:

`
var timewindows = {
windowStart: 1598979874000,
windowEnd: 1662051874000,
};

var config = {
    data: {
        resources: {
            data: dataLoaded,
            // 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.
        },
        // 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
        },
        timeWindow: {
            // Fetch the time window returned as an object with the format
            start: 'windowStart', // The start of the time window is provided with the 'windowStart' property of the returned time window object
            end: 'windowEnd', // The end of the time window is provided with the 'windowStart' property of the returned time window object
            url: timewindows,
        },
    },
    toolbar: [
        'title',
        'search',
        'separator',
        {
            type: 'button',
            text: 'Refresh',
            fontIcon: 'fa fa-refresh fa-lg',
            onclick: function (ctx) {
                ctx.gantt.draw();
            },
        },
        'fitToContent',
        'zoomIn',
        'zoomOut',
    ],
    title: '@Resources.Planning',
};

new Gantt('gantt', config);`

I tried differents formats of date in object, but the same error.

Could anyone help me? Thanks.

Error:
Error initializing the Gantt : Could not configure data for timeWindow. Probably a configuration issue with key(s) start,end checkFetcher@http://localhost:50863/Scripts/ibm-gantt-chart-jquery.js:4074:17 setConfiguration@http://localhost:50863/Scripts/ibm-gantt-chart-jquery.js:4201:21 GanttModel@http://localhost:50863/Scripts/ibm-gantt-chart-jquery.js:750:14 GanttModel@http://localhost:50863/Scripts/ibm-gantt-chart-jquery.js:4060:125 createModel@http://localhost:50863/Scripts/ibm-gantt-chart-jquery.js:7946:19 setConfiguration@http://localhost:50863/Scripts/ibm-gantt-chart-jquery.js:7914:27 GanttPanel/_this.initPromise<@http://localhost:50863/Scripts/ibm-gantt-chart-jquery.js:7716:20

missing tooltip bug with ibm gantt chart

Hi there,

I have partially integrated multiple ibm gantt chart into a single page. But I cannot figure out why I cannot get any tooltip to show up on any of the bars. Any ideas? Is there anything special that I need to load?

I'm using the plain vanilla version method of loading the files. Please note that I am also using the Datatable Editor as well. I'm not sure if this has any impact as well...

G

Change text with mouse over event on activities

Hi,
Is possible to change text content or add a new column with mouse over event on activities?
e.g. default card with mouse over a activity shown

| Name
| Start
| End
| ID

many thanks.

Detached Nodes Memory Leak

Use Case: Dashboard that displays Gantt Chart and refreshes the Gantt Chart with new data at certain intervals.

What ends up happening in heap snapshots is a ballooning of Detached Nodes, Divs, Table Elements, etc and really hurts the page performance. When checking out what they are, it's all the html associated within the gantt chart.

Snapshot:
Screen Shot 2022-03-17 at 9 09 43 AM

That's just some of them, it also includes all table row elements and every refresh adds another instance of all these elements.

Here is how I render the Gantt Chart (it is within a react component):
Screen Shot 2022-03-17 at 9 11 33 AM

I have tried extending this code to target those specific elements and remove them as well before rendering, but that doesn't appear to solve the issue. Is there something I can change to prevent this issue?

Cross-Site Scripting (XSS) in ibm-gantt-chart

Description

ibm-gantt-chart is vulnerable to Cross-Site Scripting (XSS).

Steps To Reproduce

  1. Open https://www.npmjs.com/package/ibm-gantt-chart
  2. Copy the code from the usage example and make a test.html https://www.npmjs.com/package/ibm-gantt-chart#usage
  3. And use <link href="https://unpkg.com/[email protected]/dist/ibm-gantt-chart.css" rel="stylesheet" /> and
    <script src="https://unpkg.com/[email protected]/dist/ibm-gantt-chart.js"></script>
  4. Insert the xss payload in name field in data Ex: name: 'Bethanie"<img src=x onerror=alert(1)>',
  5. Open the test.html file in any browser, XSS payload will get executed.
    ibm-gantt-chart

docs: Gantt type should not be a string

From the Data > Overview section of the Storybook;

Here is a schematic code for configuring an activity chart:

 var gantt = new Gantt( { type: 'Gantt.type.ACTIVITY_CHART', ... });

But if type is expressed as a string, the component results in "No data available in table", while removing the quotes makes it work.

gantt intl util breaks when formatting message

formatString(tpl, obj) {
// tpl = this.getString(tpl, tpl);
// return tpl.replace(/{(\w+)}/g, (_, key) => obj[key]);
return this.getIntl().formatMessage({ id: key, defaultMessage: defaultValue }, obj);
},

This code breaks when entering erroneous things in the DO4WS Dashboard's gantt editor (like a bad column name...). The error stack is:

Uncaught (in promise) ReferenceError: key is not defined
at Object.formatString (utils.js:320)
at ErrorHandler.convertError (index.js:207)
at ErrorHandler.addError (index.js:106)
at GanttPanel.setConfiguration (ganttpanel.js:245)
at ganttpanel.js:53

Unable to load multiple ibm gantt charts on the same page.

I have setup my code to load 3 gantt charts on the same page. I got first gantt chart working all the time but the second and third gantt chart works sometimes. My code seems to be erroring out on the *.load mechanism but only on the second and third gantt chart. Any ideas?

Do you have an example with documentation on how to setup multiple gantt charts (using JSON url fetching) on the same page

My Example code:

 

       // # {{{ GENERATE GANTT IBM 1 - DEVICE CHART
       function generate_gantt_ibm_1(gantt) {
           $.getJSON("./scripts/serverside_processing.cgi", {JSON_DATES_IBM_GANTT: 1 }, function(data) {
               gantt.load({
                     // 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
                     }
               });
               
           });
       }
       // # }}}
       // # {{{ GENERATE GANTT IBM 2 - ENGINEER RESOURCING
       function generate_gantt_ibm_2(gantt) {
           $.getJSON("./scripts/serverside_processing.cgi", {JSON_DATES_IBM_GANTT_ENG: 1 }, function(data) {
               gantt.load({
                     // 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
                     }
               });
               
           });
       }
       // # }}}
       // # {{{ GENERATE GANTT IBM 3 - FAMILY GENERATION
       function generate_gantt_ibm_3(gantt) {
           $.getJSON("./scripts/serverside_processing.cgi", {JSON_DATES_IBM_GANTT_FAMILY: 1 }, function(data) {
               gantt.load({
                     // 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
                     }
               });
               
           });
       }
       // # }}}

       $(document).ready(function() {


           var ibm_gantt_chart_1 =  new Gantt('gantt' /* the id of the DOM element to contain the Gantt chart */, config);
           var ibm_gantt_chart_2 =  new Gantt('gantt_2' /* the id of the DOM element to contain the Gantt chart */, config2);      
           var ibm_gantt_chart_3 =  new Gantt('gantt_3' /* the id of the DOM element to contain the Gantt chart */, config);

           generate_gantt_ibm_1(ibm_gantt_chart_1);
           generate_gantt_ibm_2(ibm_gantt_chart_2);
           generate_gantt_ibm_3(ibm_gantt_chart_3);

...
`

I don't succeed in showing data

Hi there, I'm surely missing something here, but can't find it out from the docs...

I pass a config like so:

const config = {
    type: 'Gantt.type.ACTIVITY_CHART',
    data: {
        activities: {
            data: tasks,
            id: 'id',
            start: 'Début', // The start of the activity is provided with the start property of the model object
            end: 'Fin', // The end of the activity is provided with the end property of the model object
            name: 'Nom', // The name of the activity is provided with the name property of the model object
        },
        dateFormat: 'dd/MM/yyyy HH:mm',
    },
    // 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: 'Planning', // Title for the Gantt to be displayed in the toolbar
};

const GanttIBM = (props) => {
    return <GanttChart config={config} />;
};

Where tasks is coming from a JSON :

[
  {
    "id": 1,
    "WBS": "1",
    "Nom": "TRAVAUX",
    "Durée": 230,
    "Début": "05/04/2021 09:00",
    "Fin": "18/02/2022 18:00",
    "Prédécesseurs": 10
  },
  {
    "id": 2,
    "WBS": "1.1",
    "parent": "1",
    "Nom": "Bâtiment A",
    "Durée": 100,
    "Début": "05/04/2021 09:00",
    "Fin": "20/08/2021 18:00",
    "Prédécesseurs": ""
  },
  ...
]

It keeps erroring with Cannot read property 'length' of undefined on rows.length in the model.load() promise :

return this.model.load().then(function (rows) {
        var wnd = _this5.getTimeWindow();

        if (!wnd || !wnd.start) {
          if (!rows.length) { // <---------------------------------- HERE
            // Empty Gantt, this is ok
            var today = new Date().getTime();
            var day = 1000 * 3600 * 24;

            _this5.setTimeWindow({
              start: today - day * 2,
              end: today + day * 2
            });
          } else {
            stopLoading();
            return promise_default.a.reject(core["a" /* default */].utils.getString('gantt.error.no-time-window-defined'));
          }
        }
...

I tried with different shapes for tasks like { activities: tasks } , but no luck.

Any idea what I'm doing wrong ? 🤔
I already spent several hours there...

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.