Problem
The gannt chart is able to display well when using the tasks. However when you try to add the subtasks dynamically to the series object, it generates the error below.
This error does not show if you are using static data, it only shows when you load the subtasks dynamically.
ErrorUncaught TypeError: Cannot read property 'push' of undefined at gantt.src.js:1119 at Array.forEach (<anonymous>) at gantt.src.js:1118 at Array.forEach (<anonymous>) at getListOfParents (gantt.src.js:1115) at Object.getTree (gantt.src.js:1195) at getTreeGridFromData (gantt.src.js:3607) at gantt.src.js:3688 at Array.forEach (<anonymous>) at Chart.onBeforeRender (gantt.src.js:3631)
I have tried both options of using the GanttChart::widget([]) and also utilising the javascript library directly.
Highcharts.ganttChart
Steps to reproduce
<?php
use yii\bootstrap4\Html;
use yii\helpers\Url;
//use miloschuman\highcharts\GanttChart; // iam not using this method for now.
use miloschuman\highcharts\HighchartsAsset;
use yii\web\JsExpression;
use yii\web\View;
HighchartsAsset::register($this)->withScripts([ 'modules/gantt','modules/exporting']);
?>
<div class = "card">
<div id = "chart-container"></div>
</div>
<?php
$script = <<< JS
$('document').ready(function($){
var chartData = [] ; // load it from the server
// THE CHART
Highcharts.ganttChart('chart-container', {
title: {
text: 'Highcharts Gantt With Subtasks'
},
series: [{
name: 'Project 1',
data: chartData
}]
});
}
}
sample chartData
I am loading this data from the server. so please use the dynamic data.
JSON data.
Problem The gannt chart is able to display well when using the tasks. However when you try to add the subtasks dynamically to the series object, it generates the error below. This error does not show if you are using static data, it only shows when you load the subtasks dynamically. Error
Uncaught TypeError: Cannot read property 'push' of undefined at gantt.src.js:1119 at Array.forEach (<anonymous>) at gantt.src.js:1118 at Array.forEach (<anonymous>) at getListOfParents (gantt.src.js:1115) at Object.getTree (gantt.src.js:1195) at getTreeGridFromData (gantt.src.js:3607) at gantt.src.js:3688 at Array.forEach (<anonymous>) at Chart.onBeforeRender (gantt.src.js:3631)
I have tried both options of using the GanttChart::widget([]) and also utilising the javascript library directly. Highcharts.ganttChartSteps to reproduce
sample chartData I am loading this data from the server. so please use the dynamic data. JSON data.