I have a google gantt chart that I have finally got all of the information in. I have had to use the palette [ ] to add in the colours (from Customize the bar colors in Google Gantt Charts) I want based on if the task is the project main, overdue, in date, being reviewed or complete. This worked while I had all of those variables in as an individual different resource. But then I changed a task status to being reviewed from overdue. This meant no tasks were overdue anymore. Which made any colour specifications after the overdue colour different, what resource colour came after overdue became the red overdue colours and everything else moved back one. throwing the colour scheme off entirely. My only work around looks meh in my opinion and that is forcing a record with each of the resources specified in order with the start date that of the project and one day of duration. Is there a way I can hide the Key rows (always the first 5/6) so I only have the data from the tasks. I'm hoping I'm just doing something wrong but from what it seems The Google Gantt Chart has been in beta for years.
Code below.
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {
'packages': ['gantt']
});
google.charts.setOnLoadCallback(drawChart);
function daysToMilliseconds(days) {
return days * 24 * 60 * 60 * 1000;
}
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Task ID');
data.addColumn('string', 'Task Name');
data.addColumn('string', 'Status');
data.addColumn('date', 'Start Date');
data.addColumn('date', 'End Date');
data.addColumn('number', 'Duration');
data.addColumn('number', 'Percent Complete');
data.addColumn('string', 'Dependencies');
data.addRows([ ['Key_title', 'Key','Project',new Date(2023, 4, 24), null, 1, null, null],
['Key_1', 'Project','Project',new Date(2023, 4, 24), null, 1, null, null],
['Key2', 'Overdue','Overdue', new Date(2023, 4, 24), null, 1, null, null],
['Key3', 'In date','In date', new Date(2023, 4, 24),null , 1, null, null],
['Key4', 'Complete','Complete', new Date(2023, 4, 24),null , 1, null, null],
['Key5', 'Under Review','Under Review', new Date(2023, 4, 24), null, 1, null, null],
['proj_1', 'First Project','Project', new Date(2023, 4, 24), new Date(2023, 7, 24), null, null, null], ['p_2', 'Task 2','Overdue',
new Date(2023, 4, 24), new Date(2023, 6, 13), null, 70 , null], ['s_5', 'Sub on Task 2','Complete' ,
null, new Date(2023, 6, 26),daysToMilliseconds(1), 100, 'p_2'], ['p_1', 'First Task','In date',
new Date(2023, 4, 25), new Date(2023, 6, 28), null, 74 , null], ['s_1', 'sub tsk','Complete' ,
null, new Date(2023, 6, 25),daysToMilliseconds(3), 100, 'p_1'], ['s_2', 'subtsk 2','Complete' ,
null, new Date(2023, 6, 26),daysToMilliseconds(2), 100, 'p_1'], ['s_3', 'Task Name date testing','Under Review' ,
null, new Date(2023, 6, 26),daysToMilliseconds(8), 90, 'p_1'] ]); var options = {
height: 900,
gantt: {
trackHeight: 50,
labelStyle: {
fontName: 'Arial',
fontSize: 17
},
palette: [
{
'color': '#4D4D48',
'dark': '#030303',
'light': '#969696'
},
{
'color': '#8C0202',
'dark': '#541717',
'light': '#CF6A6A'
},
{
'color': '#119100',
'dark': '#2F6628',
'light': '#62C257'
},
{
'color': '#04BFD4',
'dark': '#0098A6',
'light': '#00EAFF'
},
{
'color': '#B8B800',
'dark': '#6B6B2F',
'light': '#EBEB70'
}
]
}
}; var chart = new google.visualization.Gantt(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
</html>
The above currently gives me current results
I had it all working while there was a resource of each type, but not every project will have a late task, or complete. Happy to add more information if required.
EDIT: I tried adding in data.hideRows([1,2,3,4,5]); above the var chart - new google.visulization...
but the following error comes up, same for data.hideColumns VM12694:37 Uncaught (in promise) TypeError: data.hideRows is not a function at drawChart (eval at (jquery-1.11.0.min.js:2:2616), :37:96)