Hello all ! This year i finish my college and i need to make a c# app about "Tasks managements into a project " . I need to create a Gantt Chart that show the activity, period of time and task/project for one selected employees. Can someone help me with this type of graffic? I have a DB with SQL server.
I don`t have money to pay for plugins or something like this. Thanks a lot !
If you have any ideas, hints , leave me a comment. Thanks !

Tuhin PaulRank #7 · 71.9K reputationPosted Feb 18, 2024, 9:15 AM EST
Creating a Gantt Chart for task management in a C# application can be accomplished using various libraries and frameworks available. Since you mentioned that you don't have the budget for paid plugins or libraries, I'll suggest using open-source options.
// Assuming you have retrieved tasks data from the database List tasks = GetTasksForEmployee(selectedEmployeeId); // Format tasks data into Google Charts compatible format StringBuilder ganttChartData = new StringBuilder(); ganttChartData.Append("["); foreach (var task in tasks) { ganttChartData.Append("['"); ganttChartData.Append(task.Name); ganttChartData.Append("', '"); ganttChartData.Append(task.Project); ganttChartData.Append("', new Date("); ganttChartData.Append(task.StartDate.Year); ganttChartData.Append(", "); ganttChartData.Append(task.StartDate.Month - 1); // Months in JS are zero-based ganttChartData.Append(", "); ganttChartData.Append(task.StartDate.Day); ganttChartData.Append("), new Date("); ganttChartData.Append(task.EndDate.Year); ganttChartData.Append(", "); ganttChartData.Append(task.EndDate.Month - 1); // Months in JS are zero-based ganttChartData.Append(", "); ganttChartData.Append(task.EndDate.Day); ganttChartData.Append(")],"); } ganttChartData.Append("]"); // Inject the generated data into your HTML page string html = @" google.charts.load('current', {'packages':['gantt']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Task ID'); data.addColumn('string', 'Task Name'); data.addColumn('string', 'Resource'); 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(" + ganttChartData.ToString() + @"); var options = { height: 400 }; var chart = new google.visualization.Gantt(document.getElementById('chart_div')); chart.draw(data, options); } "; // Display the HTML page in your C# application // (This depends on your application framework, e.g., ASP.NET, WinForms, WPF, etc.)ionut8 reputationPosted Feb 20, 2024, 5:52 PM EST
Thanks for your answer, but unfortunatelly not works. It seems there are some mistakes at the html part!