Search code examples
user-interfacegantt-charttaipy

Using Gantt chart with datetime with Taipy


I’m trying to build a Gantt chart but I don’t get what I expected. Following the documentation, here is what I did.

I’ve got the following dataframe :

start end duration press label color 0 2022-10-22 00:00:00 2022-10-22 01:00:48 1970-01-01 01:00:48 WCINY_16 1303237XSW #31e374 1 2022-10-22 01:21:48 2022-10-22 03:21:00 1970-01-01 01:59:12 WCINY_16 1735973JET_1736247JET #c8fb49 2 2022-10-22 03:42:50 2022-10-22 06:06:34 1970-01-01 02:23:44 WCINY_16 54525 #434b 3 2022-10-22 06:28:24 2022-10-22 09:42:46 1970-01-01 03:14:22 WCINY_16 1341533XSW #16552c 4 2022-10-22 10:04:36 2022-10-22 15:55:00 1970-01-01 05:50:24 WCINY_16 1303237XSW #8d1032 5 2022-10-22 16:17:20 2022-10-22 18:13:03 1970-01-01 01:55:43 WCINY_16 1212583XSW #db8572 6 2022-10-22 18:33:51 2022-10-22 22:57:51 1970-01-01 04:24:00 WCINY_16 1735973JET_1736247JET #49e61c

And the chart :

<|{tp_ganttchart_description}|chart|type=bar|orientation=h|x[1]=duration|base[1]=start|y[1]=press|text[1]=label|color[1]=color|>

I get a gantt chart but the starting / ending date time does not make any sense. What am I missing ?

Regards,


Solution

  • Your code seems fine.

    The source of the problem on the Gantt chart may come from the timezone given to the columns for dates. Taipy tries to convert data automatically depending on the timezone given in the data frames and the timezone of the Web client. This can create a delay for the dates that are displayed on the chart.

    df[‘column_date’] = df[‘column_date’].dt.tz_localize(‘UTC’)
    

    This code localizes the dates of a column to have the ‘UTC’ timezone and avoids delays on charts. Converting date columns to strings would have the same effect.