How To Create An Interactive Gantt Diagram In Python Using Plotly & Excel | Step-by-Step Tutorial

Поділитися
Вставка
  • Опубліковано 3 жов 2024
  • 👉 Explore All My Excel Solutions: pythonandvba.c...
    𝗗𝗘𝗦𝗖𝗥𝗜𝗣𝗧𝗜𝗢𝗡
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    In this tutorial, I will show you, how to create a Gantt Diagram in Python.
    The data is coming directly from an Excel file.
    You can do all the changes in the excel file and after running the code again you will have your updated Gantt Diagram.
    The Gantt Chart is interactive and will be saved as an HTML file.
    You can download the code & excel file here:
    github.com/Sve...
    𝗧𝗢𝗢𝗟𝗦 𝗔𝗡𝗗 𝗥𝗘𝗦𝗢𝗨𝗥𝗖𝗘𝗦
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    🆓【𝗙𝗥𝗘𝗘】Excel Add-in (𝗠𝘆𝗧𝗼𝗼𝗹𝗕𝗲𝗹𝘁): pythonandvba.c...
    📊 Dashboard Excel Add-In (𝗚𝗿𝗮𝗳𝗹𝘆): pythonandvba.c...
    🎨 Cartoon Charts Excel Add-In (𝗖𝘂𝘁𝗲𝗣𝗹𝗼𝘁𝘀): pythonandvba.c...
    🤪 Fun Emoji Excel Add-In (𝗘𝗺𝗼𝗷𝗶𝗳𝘆): pythonandvba.c...
    📑 Excel Templates: pythonandvba.c...
    🎓 My Courses: pythonandvba.c...
    📚 Books, Tools, and More: pythonandvba.c...
    𝗖𝗢𝗡𝗡𝗘𝗖𝗧 𝗪𝗜𝗧𝗛 𝗠𝗘
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    🔗 LinkedIn: / sven-bosau
    📸 Instagram: / codingisfun_official
    💻 GitHub: github.com/Sve...
    💬 Discord: pythonandvba.c...
    📬 Contact: pythonandvba.c...
    ☕ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲?
    If you want to support this channel, you can buy me a coffee here: pythonandvba.c...

КОМЕНТАРІ • 88

  • @ajayjoseph8722
    @ajayjoseph8722 Рік тому +1

    Drag and drop and resize tasks dynamically will be amazing.

    • @CodingIsFun
      @CodingIsFun  Рік тому

      Thank you for watching the video and taking the time to leave a comment!

  • @florianroeseler2404
    @florianroeseler2404 3 роки тому +4

    Underrated channel!

  • @Slayvantz
    @Slayvantz 4 роки тому +3

    This was great! Now I just have to figure out how to get it to work with time instead of dates! Thanks for getting me started.

    • @CodingIsFun
      @CodingIsFun  4 роки тому +1

      Thank you! Do you mean something like this [example image]: ibb.co/8rvW0qC
      If yes, I have create this version for you [download link to files]:
      drive.google.com/file/d/1tZI8LPMsAtlp1VV5wpHtBRI73VjPjgLs/view?usp=sharing
      Hope that helps!

    • @Slayvantz
      @Slayvantz 4 роки тому +1

      @@CodingIsFun Yes! Thank you! I figured that earlier, didn't realize you had to conform to a certain format. I'm currently trying to get two lines of data on one horizontal bar. So kind of like you have in your example but there would be another "start" and "finish".

    • @CodingIsFun
      @CodingIsFun  4 роки тому

      Do you mean something like this?
      ibb.co/LrnxfGq

    • @Slayvantz
      @Slayvantz 4 роки тому +1

      @@CodingIsFun close the columns would read as Task, Start, Finish, Start2, Finish2, Complete in % if that makes any sense

    • @CodingIsFun
      @CodingIsFun  4 роки тому

      Alright, I think you would like to have something like this [example image]: ibb.co/KrvTWwn
      Here is the source code:
      drive.google.com/file/d/1W_wPxaClHF0OwTmvHPFWOZI99imxM-fE/view?usp=sharing

  • @jackychan1644
    @jackychan1644 4 роки тому +1

    Amazing! Works perfectly! Thanks

  • @0spacetraveller
    @0spacetraveller 4 роки тому +1

    Thank you! Great tutorial!

  • @mikepetersen5662
    @mikepetersen5662 2 роки тому

    Thank you so much for this great tutorial!

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Glad you enjoyed it! Thanks for watching! :)

  • @shashvatverma5673
    @shashvatverma5673 Рік тому

    Pretty cool tool. Can't believe how many free online tools require a payment now, just to use their most basic gantt chart making tools.

    • @CodingIsFun
      @CodingIsFun  Рік тому +1

      Happy to hear that it was useful; thank you for taking the time to leave a comment and for watching the video!

  • @jayanthnmurthy
    @jayanthnmurthy 3 роки тому +1

    Danke für dieses tolle Video :)

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      Danke! Es freut mich, dass es dir gefallen hat. 😃

  • @py_tok5589
    @py_tok5589 3 роки тому

    very cool mate, thank you, new sub here

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      *I am glad you liked the video, thanks for watching and for the comment!* Cheers ✌

  • @cibi6234
    @cibi6234 3 роки тому +3

    hey! thanks so much for this video. i'm doing a university project in visualization with python and this helped me so much to get started. I was wondering if you could give me a tip for the most beginner friendly way of making an animated gantt chart in python (so far i couldnt make it work in plotly but maybe you have a tip. Could be basically any library the main thing would be that its possible :D Thanks so much for your asnwer in advance.

    • @CodingIsFun
      @CodingIsFun  3 роки тому +1

      Hi,
      thank you for your comment.
      I actually do think, that Plotly(express) is one of the most beginner-friendly libraries to create an interactive Gantt chart. With just a few lines of code, you can get stunning results.
      Cheers,
      Sven

  • @PJMScheduling
    @PJMScheduling 2 роки тому +2

    Amazing tutorial! I'm new to Python so forgive me if this is a dumb question, but is there a way using plotly to add a scroll bar to the gantt chart? My schedules can be 1,000s of activities and I'm trying to find a way to not compress the entire gantt chart onto one window. Cheers!

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      Thank you! Excellent question! I have checked the Plotly documentation, but I could not find a way to add a scroll bar to the Gantt chart. 😕

    • @PJMScheduling
      @PJMScheduling 2 роки тому +1

      @@CodingIsFun Thanks for looking and for the reply! Really appreciate it.

  • @jawwadrezanoor913
    @jawwadrezanoor913 3 роки тому

    Thank you. This was very helpful. I was just wondering how to allocate different colors (i.e., colors other than the default black) without the % completion data (meaning, all values in % completion column = 0)

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      Thanks for watching the video. Usually, the colour is indicated by the completion rate. Would you like to ignore the completion column and set a different colour for each task?
      E.g.
      Task 1: Red
      Task2: Blue

    • @jawwadrezanoor913
      @jawwadrezanoor913 3 роки тому

      @@CodingIsFun Yes. In fact, I would like only single color for all bars. But if you can additionally show how to allocate multiple colors (e.g., Task1: Red, Task2: Blue), then that's also fine.

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      @@jawwadrezanoor913 I went ahead and modified the code for you.
      Please find
      the code here: gist.github.com/Sven-Bo/4b6dc57dcaacb38002eb4b82f7ce22f4
      the result will look like this: www.screencast.com/t/xtLHTJUAvylM
      import plotly.express as px
      import plotly
      import pandas as pd
      # Read Dataframe from Excel file
      df = pd.read_excel("Tasks.xlsx")
      # Assign Columns to variables
      tasks = df["Task"]
      start = df["Start"]
      finish = df["Finish"]
      # Create Gantt Chart
      fig = px.timeline(
      df,
      x_start=start,
      x_end=finish,
      y=tasks,
      title="Task Overview",
      color_discrete_sequence=["#F63366"] * len(df),
      )
      # Upade/Change Layout
      fig.update_yaxes(autorange="reversed")
      fig.update_layout(title_font_size=42, font_size=18, title_font_family="Arial")
      # Save Graph and Export to HTML
      plotly.offline.plot(fig, filename="Task_Overview_Gantt.html")
      Hope you like the solution :)

  • @jamilhassan9491
    @jamilhassan9491 3 роки тому +1

    Thanks for this video, that's helpful but i'm wondering if there is any way to add a "Comments" column in the excel file in order to add a hover text in the gantt chart?

    • @CodingIsFun
      @CodingIsFun  3 роки тому +2

      Thanks for watching & your comment.
      I have created this solution for you:
      👉 drive.google.com/file/d/1uecsVpQd2gPXxaEadRdScn_-ufxujbKM/view?usp=sharing
      It will look like this:
      👉 snipboard.io/FSpX4o.jpg
      Hope it works for you 😃
      Cheers,
      Sven

    • @jamilhassan9491
      @jamilhassan9491 3 роки тому +1

      @@CodingIsFun Many thanks for your quick answer ;). Yesterday i got the same result as you on the "standard" Gantt chart but that does not work on the interactive one (sorry my question was not enough precise). I tried also to update the fig by using fig.update_traces(hovertext=comments), the update works but comments are not matching with bars (and i have different comments on start and finish position on the same bar).

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      @@jamilhassan9491 Alright, gotcha. I have created the following example for you:
      👉 snipboard.io/De3byN.jpg
      You can download it here:
      👉 drive.google.com/file/d/1nHv-x1LV2ceCQmgeWRGlvd5sJBJev7BK/view?usp=sharing
      In the Excel File, you want to make sure to name the header "Description"
      Hope this solution works for you.
      Cheers,
      Sven

    • @jamilhassan9491
      @jamilhassan9491 3 роки тому +2

      Many thanks it's working fine now :D

  • @farazmehdi9019
    @farazmehdi9019 2 роки тому

    Appreciate the tutorial. It helped me a lot. Curious if we can add dependencies to the Gantt chart.

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thanks for watching the video & your question. What exactly do you mean by dependencies? Could you please provide more information? Thanks!

    • @farazmehdi9019
      @farazmehdi9019 2 роки тому

      @@CodingIsFun Thanks for the quick response. A traditional Gantt chart can have information that the start of a particular task is dependent on the finish of another task. It is typically represented by connecting arrows showing the flow of information.

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      @@farazmehdi9019 Thanks for the further input. I had a look at the Plotly documentation ( plotly.com/python/gantt/ ), but it seems that this is not possible😕

    • @farazmehdi9019
      @farazmehdi9019 2 роки тому

      @@CodingIsFun I personally think those arrows do not serve a whole lot of purpose but people are just used to them. Thanks for looking into it.

  • @nailialaeddine1168
    @nailialaeddine1168 2 роки тому

    Amazing tutorial ! thanks so much for this video.i'm doing a university project in visualization with python and this helped me so much to get started.
    I'm new to Python so forgive me if this is a dumb question :
    Is there a way to manipulate the bars by using the mouse in the image,for example assemble or return , or is there another way?But i want in the same thing(time line),Another library !!, I don't know !?
    I hope for an answer.
    Thanks in advance 😊

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      Thanks for watching the video. I am not sure if I understand you correctly. Would you like to execute/return a Python function when clicking the bar? Could you maybe provide some more information? Thanks!

    • @nailialaeddine1168
      @nailialaeddine1168 2 роки тому

      @@CodingIsFun If the tape is of the same type or color, I want when I click on it, I can move it and combine it with another tape by mouse
      (Interactive image is not for display only i want change some with mouse )
      Briefly I'm looking for something change the input table data by changing the image with the mouse (Interactive display picture)
      Thank you very much

    • @nailialaeddine1168
      @nailialaeddine1168 2 роки тому

      @@CodingIsFun I want timeline output like this when i click with the mouse to change place of tasks ,in the same can change the dataframe also
      can you help me in this problem

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      @@nailialaeddine1168 Thanks for the further input. As far as I know, this is not possible with Plotly, and I do not know any other library with that feature. Sorry!

  • @imranmasoud1849
    @imranmasoud1849 3 роки тому

    Thank you so much. I want to try this but just to publish my excel table as is. Would it work with this code?

    • @CodingIsFun
      @CodingIsFun  3 роки тому +1

      Thank you for watching the video. Sorry, I am not quite sure what your concern is. Would you like to know if the code works if your excel data is formatted as a table? If so, the answer would be yes 😃

    • @imranmasoud1849
      @imranmasoud1849 3 роки тому

      Thanks for responding too!
      What I mean is that i dont need to make a gantt chart. Just need to show my excel data on a browser as a table with the same formatting as it appears on excel. I know its probably a silly question but im not a coder so im just trying it out.

    • @CodingIsFun
      @CodingIsFun  3 роки тому +2

      @@imranmasoud1849 Ok understood. I think the easiest way would be to save your Excel workbook as a web page. See screenshot below:
      prnt.sc/12kpi7v
      Hope you like the solution 🙏

  • @pauladdison6331
    @pauladdison6331 3 місяці тому

    I had an error in powershell when trying to print output. I installed additional library openpyxl and this seemed to fix the problem. In case anyone else facing similar issue.

    • @CodingIsFun
      @CodingIsFun  3 місяці тому +1

      Thanks for the hint. I added it to the requirements.txt file on GitHub. Cheers, Sven ✌️

  • @TriNguyen-xi8ji
    @TriNguyen-xi8ji 3 роки тому

    Plotly is cool but it is a complete mess regarding Gantt chart. In my case, the bar heights are completely random. Some is like a thread of hair thick, some take literally a quarter of my screen's height. I have looked up and find out that many people are experiencing the same problem and there seem to be no effective way to overcome this just yet.

    • @CodingIsFun
      @CodingIsFun  3 роки тому +1

      Thanks for watching the video & sharing your experience with the Plotly Gantt chart 👍

  • @kkkokk128
    @kkkokk128 2 роки тому

    is it able to change the x-axis from time to numeric positions?(like 1-10000)

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thanks for watching. I am not sure if that is possible.

  • @nailialaeddine1168
    @nailialaeddine1168 2 роки тому

    hey! Is it possible to put colors in the background of the interface specify a specific time
    For example, every day a color or every month a color
    something like this
    !?
    I hope for an answer.
    Thanks in advance 😊

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      Thanks for watching. I am not sure what you are trying to achieve.
      So, January should be red, February blue, March green, ...?
      And all the tasks in the month should be coloured accordingly? E.g. tasks in February should be marked blue?
      You might want to check out the documentation to see what is possible:
      plotly.com/python-api-reference/generated/plotly.express.timeline.html
      Happy Coding!

    • @nailialaeddine1168
      @nailialaeddine1168 2 роки тому

      @@CodingIsFun i mean the same Gantt Diagram in your example in the video
      But I mean the background of the Gantt chart every month or every year (in a faint color for example), any light colors behind the task

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      ​@@nailialaeddine1168 In the current script, I am update the layout as follows:
      fig.update_layout(title_font_size=42, font_size=18, title_font_family="Arial")
      You can add additional params, see below:
      fig.update_layout(title_font_size=42, font_size=18, title_font_family="Arial", plot_bgcolor=rgba(0, 0, 0, 0), paper_bgcolor=rgba(0, 0, 0, 0))

  • @umyaor
    @umyaor 3 роки тому

    That's a great tutorial. One thing I could not figure out is the date in my Gantt chart always start from 1970. It looks like the date was not read from my excel file somehow. Do you know how to fix it? Thank you.

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      *Hi Ray Yao. I am glad you liked the video, thanks for watching and for the question!*
      Did you try already to format the cell in Excel as a 'Date' (see example below):
      prnt.sc/11u201x

    • @umyaor
      @umyaor 3 роки тому

      @@CodingIsFun Thanks for your response. I just downloaded your excel file and copied date columns to my excel and it worked out perfect. Does it only work with the date format you picked such as 2012-03-14?

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      @@umyaor Sorry for my late response, I was at work.
      You could also change it directly in Plotly by updating the x-axes:
      fig.update_xaxes(tickformat="%b %d, %Y")
      *Here is the example code:*
      gist.github.com/Sven-Bo/56fe035cceeed8d19bfc555bec972ff3
      *The output would look like this:*
      snipboard.io/TjKZen.jpg
      Hope it helps 🙏

  • @chemmakhabderraouf1988
    @chemmakhabderraouf1988 2 роки тому

    Thanks man for the video! I have one question, Can we justify the yticks to the left? I found no solution available yet! I tried to bypass that by adding extra spaces (all ticks with the same character count) to the left of the shorter ticks but apparently the space length is not as the letter length which makes it not possible to have all ticks start at the same (left level).

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      Sorry, but I am not quite sure what you are trying to achieve. The y-ticks are currently on the left side ( www.screencast.com/t/ZsHhwBkbn ). How would you like to position them?

    • @chemmakhabderraouf1988
      @chemmakhabderraouf1988 2 роки тому

      @@CodingIsFun thanks man for answering. I want all ticks to start from the same left level, now python plotly is filling the ytick from right to left, I want the reverse case meaning that I want the yticks to be left justified. Thanks

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      @@chemmakhabderraouf1988 Ok understood. I am not sure if that is possible. All I can do for you is to refer to the official docs, where you can find all parameters:
      plotly.com/python-api-reference/generated/plotly.express.timeline.html

  • @asarma0804
    @asarma0804 3 роки тому

    How can you make it show that the task finishes in the same day but it only took some hours?

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      Thank you! Do you mean something like this [example image]: ibb.co/8rvW0qC
      If yes, I have created this version for you [download link to files]:
      👉 drive.google.com/file/d/1tZI8LPMsAtlp1VV5wpHtBRI73VjPjgLs/view?usp=sharing
      Hope that helps!
      Cheers,
      Sven

    • @asarma0804
      @asarma0804 3 роки тому +1

      @@CodingIsFun yes thanks man I appreciate it

  • @manikantareddy2385
    @manikantareddy2385 3 роки тому

    Is it in javascript?

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      No, the code is written in Python

    • @manikantareddy2385
      @manikantareddy2385 3 роки тому

      @@CodingIsFun I want Gantt chart in JavaScript using plotly

    • @CodingIsFun
      @CodingIsFun  3 роки тому +1

      @@manikantareddy2385 I have checked the Plotly documentation: plotly.com/javascript/
      Currently, it seems that there is no Plotly Gantt Chart available in JS. 😥

    • @manikantareddy2385
      @manikantareddy2385 3 роки тому +1

      @@CodingIsFun yeah, I also checked.😟 Thanks for reply 🤝🤝