I was hoping to be able to use this JS library (https://frappe.io/gantt) inside a lightning component, initially after loading the library I was getting the error
.... $controller$doGantt [Gantt is not defined]
I was able to fix the error by replacing the main function from var Gantt to window.Gantt, however now I am getting the error
.... $controller$doGantt [bar.getX is not a function]
But I am unable to find that function inside the file
Is there anything I can do to avoid modifying the original library in order to run inside a component? or it is just better to run this inside a VF Page?
My current component looks like:
<aura:component>
<ltng:require styles="{!$Resource.gantt + '/frappe-gantt.css'}"
scripts="{!$Resource.gantt + '/frappe-gantt.js'}" afterScriptsLoaded="{!c.doGantt}" />
<h2>Interactive Gantt Chart entirely made in SVG!</h2>
<div id="myDiv" aura:id="div1" class="gantt-target"></div>
</aura:component>
And the controller:
({
doGantt : function(component, event, helper) {
var tasks = [
{
start: '2018-10-01',
end: '2018-10-08',
name: 'Redesign website',
id: "Task 0",
progress: 20
},
{
start: '2018-10-03',
end: '2018-10-06',
name: 'Write new content',
id: "Task 1",
progress: 5,
dependencies: 'Task 0'
},
{
start: '2018-10-04',
end: '2018-10-08',
name: 'Apply new styles',
id: "Task 2",
progress: 10,
dependencies: 'Task 1'
},
{
start: '2018-10-08',
end: '2018-10-09',
name: 'Review',
id: "Task 3",
progress: 5,
dependencies: 'Task 2'
},
{
start: '2018-10-08',
end: '2018-10-10',
name: 'Deploy',
id: "Task 4",
progress: 0,
dependencies: 'Task 2'
},
{
start: '2018-10-11',
end: '2018-10-11',
name: 'Go Live!',
id: "Task 5",
progress: 0,
dependencies: 'Task 4',
custom_class: 'bar-milestone'
},
{
start: '2014-01-05',
end: '2019-10-12',
name: 'Long term task',
id: "Task 6",
progress: 0
}
]
var ganttTable = component.find("div1").getElement();
var gantt_chart = new Gantt(ganttTable, tasks);
// console.log(gantt_chart);
}
})
