0
Я использую плагин jquery для создания диаграммы gantt с именем Jquery.Gantt Я хочу загрузить json-файл, но, к сожалению, он не загружается. это содержимое json-файла. он загружает json-файл через ajax, но он не отображает.Попытка загрузить json-файл в Jquery.gantt
[
{
"name": "WORK IN PROGRESS (WIP) MEETING",
"desc": ""
},{
"name":"",
"desc": "WIP Meeting",
"by": "TEST DATA",
"values": [{
"from": "/Date(2013/05/22)/",
"to": "/Date(2013/05/22)/",
"customClass": "ganttGreen"
},{
"from": "/Date(2013/06/05)/",
"to": "/Date(2013/06/05)/",
"customClass": "ganttGreen"
},{
"from": "/Date(2013/06/19)/",
"to": "/Date(2013/06/19)/",
"customClass": "ganttGreen"
},{
"from": "/Date(2013/07/03)/",
"to": "/Date(2013/07/03)/",
"customClass": "ganttGreen"
},{
"from": "/Date(2013/07/17)/",
"to": "/Date(2013/07/17)/",
"customClass": "ganttGreen"
},{
"from": "/Date(2013/07/31)/",
"to": "/Date(2013/07/31)/",
"customClass": "ganttGreen"
},{
"from": "/Date(August 7, 2013)/",
"to": "/Date(August 7, 2013)/",
"customClass": "ganttGreen"
},{
"from": "/Date(August 14, 2013)/",
"to": "/Date(August 14, 2013)/",
"customClass": "ganttGreen"
},{
"from": "/Date(August 21, 2013)/",
"to": "/Date(August 21, 2013)/",
"customClass": "ganttGreen"
},{
"from": "/Date(August 28, 2013)/",
"to": "/Date(August 28, 2013)/",
"customClass": "ganttGreen"
}]
},{
"name": "OVERALL EVENT COSTINGS",
"desc": ""
},{
"name": "a) Budget",
"desc": "Submission of preliminary budget",
"by": "TEST DATA"
},{
"name": "a) Budget",
"desc": "Submission of revised budget",
"by": "TEST DATA"
},{
"name": "",
"desc": "Confirmation and Sign-off of Budget",
"by": "TEST DATA ",
"values": [{
"from": "/Date(July 1, 2013)/",
"to": "/Date(July 7, 2013)/",
"customClass": "ganttRed"
}]
},{
"name": "",
"desc": "Billing of Deposits and Invoices",
"by": "TEST DATA",
"values": [{
"from": "/Date(July 1, 2013)/",
"to": "/Date(July 7, 2013)/",
"customClass": "ganttRed"
}]
},{
"name": "",
"desc": "Submission of final budget",
"by": "TEST DATA",
"values": [{
"from": "/Date(August 5, 2013)/",
"to": "/Date(August 18, 2013)/",
"customClass": "ganttRed"
}]
},{
"name": "",
"desc": "Confirmation and Sign-off of Final Budget",
"by": "TEST DATA",
"values": [{
"from": "/Date(August 12, 2013)/",
"to": "/Date(August 27, 2013)/",
"customClass": "ganttRed"
}]
},{
"name": "",
"desc": "Billing of Balance payments Invoices",
"by": "TEST DATA",
"values": [{
"from": "/Date(September 9, 2013)/",
"to": "/Date(September 15, 2013)/",
"customClass": "ganttRed"
}]
},{
"name":"EVENT CONCEPT, ID and TAGLINE"
},{
"name":"a) Event Concept based on revised event ID and tagline",
"desc":"Propose/Initial Event Concept",
"by":"TEST DATA",
"values": [{
"from": "/Date(April 1, 2013)/",
"to": "/Date(April 7, 2013)/",
"customClass": "ganttRed"
}]
},{
"name":"",
"desc":"Revise Event Concept based on feedback",
"by":"TEST DATA",
"values": [{
"from": "/Date(May 6, 2013)/",
"to": "/Date(May 12, 2013)/",
"customClass": "ganttRed"
}]
},{
"name":"",
"desc":"Confirmation on Event Concept",
"by":"TEST DATA",
"values": [{
"from": "/Date(May 20, 2013)/",
"to": "/Date(May 26, 2013)/",
"customClass": "ganttRed"
}]
}
]
Вот мой код для активации плагина.
$(".gantt-chart").gantt({
itemsPerPage: 15,
source: "../../public/js/gantt-sample.json",
scale: "days",
minScale: "days",
maxScale: "months",
navigate: "scroll",
onItemClick: function(data) {
console.log("Item clicked - show some details");
},
onAddClick: function(dt, rowId) {
console.log("Empty space clicked - add an item!");
},
onRender: function() {
console.log("chart rendered");
}
});
Я забыл сказать, что у меня есть ошибка: «TypeError: e undefined» Я проверил свой json-файл через jsonlint, и он действителен. –
Убедитесь, что js-код способен обрабатывать json-файл в указанном пути. Этот плагин принимает как url, так и javascript-массив в качестве источника. Таким образом, чтобы проверить, объявите переменную с исходными данными и передайте ее как источник. –