Open renatomenon opened 3 years ago
you can find an example of usage at
can you use directly
timeWindow: { start: '1598979874000', end: 1662051874000 }
?
Hello @delhoume !
I tried to use this example (https://github.com/IBM/gantt-chart/blob/60cca5558c20ea818dc512e0d60ea65c7adb6b5f/packages/ibm-gantt-chart-docs/src/docs/data_time_window.md), but I don't have sure about a date format declaration in my object.
I declared an object like this example:
var timewindows = { windowStart: 1598979874000, windowEnd: 1662051874000, };
But doesn't worked.
Using value directing in configuration, like bellow, doesn't work too.
timeWindow: { start: '1598979874000', end: 1662051874000 }
The code that shows an error is in https://github.com/IBM/gantt-chart/blob/60cca5558c20ea818dc512e0d60ea65c7adb6b5f/packages/ibm-gantt-chart/src/model/index.js#L36
and is called at
I do not know exactly why this fails and what should be the correct arguments, it seems that url should contain a path to a json object that should contains keys described in the start and end parts of the timeWindow object, so maybe defining an external file as shown in the doc works. The url is fetched then its windowStart and windowEnd keys are queried I think
it seems that url is mandatory and it must be an external file, or you will have an error.
I found that fetchers can have inline data (not urls), see https://github.com/IBM/gantt-chart/blob/60cca5558c20ea818dc512e0d60ea65c7adb6b5f/packages/ibm-gantt-chart-docs/src/docs/data_fetchers.md so you may try
timeWindow : { data: timewindows, start : 'windowStart', end : 'windowEnd' }
with timewindows beeing an array or a fonction returning an array.
Unfortunately I also tried differents ways... Using a separated json file or using a array like that bellow.
Also tried different types of date (linux epoch, ust etc) and changing the property names of start and end...
const timeWindows = {
"windowStart": 1598979874000,
"windowEnd": 1662051874000
};
var config = {
data: {
timeWindow: {
start: 'windowStart',
end: 'windowEnd',
data: timeWindows,
},
resources: {
data: dataLoaded,
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: '@Resources.Planning',
};
The same error is showed:
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
your const timeWindows = { "windowStart": 1598979874000, "windowEnd": 1662051874000 };
is not an array, can you try
const timeWindows = [ { "windowStart": 1598979874000, "windowEnd": 1662051874000 } ];
as described in doc for fetchers with the resources field ?
Maybe also the values need to be strings
const timeWindows = [ { "windowStart": "1598979874000", "windowEnd": "1662051874000" } ];
I tried using these ways but got same error
I am running out of ideas, I will try to trace source code to see what happens
In JS, this is line:
fetcher.get is undefined
I do not see why timeWindow fetcher is different from other fetchers (activities or resources)... Maybe you can try to create a function that returns the array, that would be another code path
Thank you very much @delhoume
I really don't know why TimeWindow parameter in config do not work correctly here.
Now, I edited other path code in JS to force time window and it worked for me.
If you or someone else find where is my problem using timeWindow parameter in config, let me know!
Thank you for your time and help!
You're welcome
For future users trying to solve this problem, this was the solution that worked for me:
const config = {
data: {
...,
timeWindow: () => {
return new Promise((resolve, _) => {
resolve({
start: <your start date here>,
end: <your end date here>,
});
});
},
},
};
https://github.com/IBM/gantt-chart/blob/60cca5558c20ea818dc512e0d60ea65c7adb6b5f/packages/ibm-gantt-chart/src/model/index.js#L190
This line seems to suggest the timeWindowFetcher
expects a Promise
and does not take any other forms of input into consideration.
Hope that helps!
Thank you for your solution !
path code in JS to force
I am struggling with No time window defined - doesn't help but i am quiet new at this
var dataConfig = {
resources : {
url : "/api/data3",
parent : "parent",
id : "id",
name : "name",
activities : "activities",
},
activities : {
start : function(activities) { return makeDate(activities.start); },
end : function(activities) { return makeDate(activities.end); },
name : "name",
parent : "parent",
id : "id"
},
}
var config = {
// 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: 'Marketing Swimlane',
};
// new Gantt('gantt', config);
$(document).ready(function() {
// $('#gantt').Gantt(config);
new Gantt( 'gantt', { data: dataConfig });
});`
This is my controller:
public function getProjectsTaskBusinessUnit(PickList $pickList)
{
$resources = PickList::query()->select('id', 'name', 'id as parent')
->with(['activities' => function ($query) {
$query->select('projects.id', 'projects.name', 'projects.start_date as start', 'projects.end_date as end');
}])
->where('group_by', 'business_units')
->get();
return response()->json([
"resources" => $resources,
]);
}
It seems there is a solution two posts above
I have tried what is recommended not sure what I am missing
I have this error now Loading error : Invalid start "NaN"
please show your timeWindow() code
var dataConfig = {
resources : {
url : "/api/data3",
parent : "parent",
id : "id",
name : "name",
activities : "activities",
},
activities : {
// start : function(activities) { return makeDate(activities.start); },
// end : function(activities) { return makeDate(activities.end); },
name : "name",
parent : "parent",
id : "id"
},
dateFormat : "yyyy-MM-dd'T'HH:mm:ss.SSSZ", // Format to parse date strings from.
timeWindow: () => {
return new Promise((resolve, _) => {
resolve({
start: function(activities) { return makeDate(activities.start); },
end: function(activities) { return makeDate(activities.end); },
});
});
},
}
this is the error I am getting Error: Invalid start "NaN" at n._applyRange (https://devtest.precamp.io/assets/plugins/vis/vis.min.js:27:26532) at n.setRange (https://devtest.precamp.io/assets/plugins/vis/vis.min.js:27:25523) at n.setOptions (https://devtest.precamp.io/assets/plugins/vis/vis.min.js:27:23709) at https://devtest.precamp.io/assets/plugins/vis/vis.min.js:28:9113 at Array.forEach () at n.setOptions (https://devtest.precamp.io/assets/plugins/vis/vis.min.js:28:9084) at o.setOptions (https://devtest.precamp.io/assets/plugins/vis/vis.min.js:39:19034) at new o (https://devtest.precamp.io/assets/plugins/vis/vis.min.js:39:17827) at TimeLine.setTimeWindow (https://devtest.precamp.io/assets/plugins/ibm-gantt-chart/ibm-gantt-chart-jquery.js:16157:28) at GanttPanel.setTimeWindow (https://devtest.precamp.io/assets/plugins/ibm-gantt-chart/ibm-gantt-chart-jquery.js:7825:48)
what is your makeDate function ? It should return a number as in new Date().getTime()
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, };
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