0

我正在尝试使用 init-from-csv.html(来自演示文件)导入 *.csv。我下载了 GetOrgChart zip 文件,并将链接更改为实际的 .js 和 .css 文件。

这是我的代码:

<!DOCTYPE html> <html> <head>
    <title>OrgChart | Initialize From XML</title>

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script src="D:/Tools/GetOrgChart/getorgchart/getorgchart.js"></script>
    <link href="D:/Tools/GetOrgChart/getorgchart/getorgchart.css" rel="stylesheet" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>



    <style type="text/css">
        html, body {
            margin: 0px;
            padding: 0px;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }

        #people {
            width: 100%;
            height: 100%;
        }
    </style> </head> <body>
    <div id="people"></div>
    <script type="text/javascript">

        function convertToCsvJson(allText) {
            var allTextLines = allText.split(/\r\n|\n/);
            var headers = allTextLines[0].split(',');
            var lines = [];

            for (var i = 1; i < allTextLines.length; i++) {
                var data = allTextLines[i].split(',');
                if (data.length == headers.length) {

                    var tarr = {};
                    for (var j = 0; j < headers.length; j++) {
                        tarr[headers[j]] = data[j];
                    }
                    lines.push(tarr);
                }
            }

            return lines;
        }

        $.get("D:/Tools/GetOrgChart/ORG_Data.txt", function (source) {

            source = convertToCsvJson(source);

            var peopleElement = document.getElementById("people");
            var orgChart = new getOrgChart(peopleElement, {
                theme: "helen",
                primaryFields: ["name", "Job Title"],
                photoFields: ["Photo"],
                linkType: "M",
                enableEdit: false,
                enableDetailsView: false,
                dataSource: source
            });
        });
    </script> </body> </html>

打开 HTML 文件后,它不会加载。我不确定我做错了什么。

4

0 回答 0