frappe / gantt

Open Source Javascript Gantt
https://frappe.io/gantt
MIT License
4.67k stars 1.04k forks source link

Frappé Gantt only supports usage of a string CSS selector, HTML DOM element or SVG DOM element for the 'element' parameter #236

Closed henryhu712 closed 3 years ago

henryhu712 commented 3 years ago

I create an element by the instructions of the repo:

<svg id="gantt"></svg>

But get the error: Frappé Gantt only supports usage of a string CSS selector, HTML DOM element or SVG DOM element for the 'element' parameter.

How can I fix it?

ijazfx commented 1 year ago

@henryhu712 how did you fix this issue?

Dawnw3aver commented 1 year ago

You should use gantt grawing function inside the DOMContentLoaded eventlistener. It works for me.

<script>
        document.addEventListener("DOMContentLoaded", function () {
            var tasks = [
            {
                id: 'Task 1',
                name: 'Redesign website',
                start: '2016-12-28',
                end: '2016-12-31',
                progress: 20
            }]
            var gantt = new Gantt("#gantt", tasks);
        });

    </script>