{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "from datetime import datetime\n",
    "sys.path.append('../../src')\n",
    "from pjplan import Task, DefaultScheduler, WBS, DhtmlxGantt, DhtmlxGanttColumn, task_sheet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "with WBS('Test project') as prj:\n",
    "    prj // Task(1, 'Task 1', estimate=40, resource='Tester')\n",
    "    prj // Task(2, 'Task 2', predecessors=[prj(1)], estimate=20, resource='Tester')\n",
    "    with prj // Task(3, 'Task 3') as t:\n",
    "        t // Task(4, 'Task 4', predecessors=[prj(2)], estimate=100)\n",
    "        t // Task(5, 'Task 5', predecessors=[prj(2)], estimate=50)\n",
    "    with prj // Task(6, 'Task 6') as t:\n",
    "        t // Task(7, 'Task 7', predecessors=[prj(5)], estimate=16)\n",
    "        t // Task(8, 'Task 8', predecessors=[prj(7)], estimate=16)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "plan, usage = DefaultScheduler(datetime.now()).calc(prj)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Sample project"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[92mID     NAME       START             END               PREDECESSORS \u001b[0m\n",
      "\u001b[94m     1 Task 1     27.03.2023 00:00  01.04.2023 00:00  []           \u001b[0m\n",
      "\u001b[94m     2 Task 2     03.04.2023 00:00  05.04.2023 12:00  [1]          \u001b[0m\n",
      "\u001b[94m     3 Task 3     05.04.2023 12:00  02.05.2023 06:00  []           \u001b[0m\n",
      "\u001b[96m     4    Task 4  05.04.2023 12:00  22.04.2023 00:00  [2]          \u001b[0m\n",
      "\u001b[96m     5    Task 5  24.04.2023 00:00  02.05.2023 06:00  [2]          \u001b[0m\n",
      "\u001b[94m     6 Task 6     02.05.2023 06:00  08.05.2023 06:00  []           \u001b[0m\n",
      "\u001b[96m     7    Task 7  02.05.2023 06:00  04.05.2023 06:00  [5]          \u001b[0m\n",
      "\u001b[96m     8    Task 8  04.05.2023 06:00  08.05.2023 06:00  [7]          \u001b[0m\n"
     ]
    }
   ],
   "source": [
    "task_sheet(plan)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Simple gantt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<iframe srcdoc=\"&lt;html&gt;\n",
       "&lt;meta charset=&quot;utf-8&quot;&gt;\n",
       "&lt;body&gt;\n",
       "&lt;script src=&quot;https://storage.yandexcloud.net/gymboss-test/gantt/gantt/dhtmlxgantt.js?v=7.1.13&quot;&gt;&lt;/script&gt;\n",
       "&lt;link rel=&quot;stylesheet&quot; href=&quot;https://storage.yandexcloud.net/gymboss-test/gantt/gantt/dhtmlxgantt.css?v=7.1.13&quot;&gt;\n",
       "&lt;style&gt;\n",
       "    html, body {\n",
       "        padding: 0px;\n",
       "        margin: 0px;\n",
       "        height: 100%;\n",
       "    }\n",
       "\n",
       "    .gantt_side_content.gantt_link_crossing {\n",
       "        top:0\n",
       "    }\n",
       "\n",
       "    \n",
       "&lt;/style&gt;\n",
       "&lt;div id=&quot;gantt_here&quot; style=&#x27;width:100%; height:100%;&#x27;&gt;&lt;/div&gt;\n",
       "&lt;script&gt;\n",
       "\n",
       "    gantt.plugins({\n",
       "        marker: true,\n",
       "        grouping: true\n",
       "    });\n",
       "\n",
       "    gantt.ext.zoom.init({\n",
       "        minColumnWidth: 80,\n",
       "        maxColumnWidth: 150,\n",
       "        levels: [\n",
       "            [\n",
       "                {unit: &quot;year&quot;, format: &quot;%Y&quot;, step: 1},\n",
       "                {unit: &quot;month&quot;, format: &quot;%M&quot;, step: 1},\n",
       "            ],\n",
       "            [\n",
       "                {unit: &quot;month&quot;, format: &quot;%M %Y&quot;, step: 1},\n",
       "                {\n",
       "                    unit: &quot;week&quot;, step: 1, format: function (date) {\n",
       "                        var dateToStr = gantt.date.date_to_str(&quot;%d.%m&quot;);\n",
       "                        var endDate = gantt.date.add(date, -6, &quot;day&quot;);\n",
       "                        return dateToStr(date) + &quot; - &quot; + dateToStr(endDate);\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            [\n",
       "                {unit: &quot;month&quot;, format: &quot;%M %y&quot;, step: 1},\n",
       "                {unit: &quot;day&quot;, format: &quot;%d.%m&quot;, step: 1}\n",
       "            ]\n",
       "        ],\n",
       "        useKey: &quot;ctrlKey&quot;,\n",
       "        trigger: &quot;wheel&quot;,\n",
       "        element: function () {\n",
       "            return gantt.$root.querySelector(&quot;.gantt_task&quot;);\n",
       "        }\n",
       "    });\n",
       "\n",
       "    gantt.config.min_column_width = 20;\n",
       "    gantt.config.auto_types = true;\n",
       "\n",
       "    if (true) {\n",
       "        gantt.addMarker({\n",
       "            start_date: new Date(),\n",
       "            css: &quot;today&quot;,\n",
       "        });\n",
       "    }\n",
       "\n",
       "    gantt.config.columns = [];\n",
       "\n",
       "    gantt.config.row_height = 25;\n",
       "\n",
       "    (function () {\n",
       "        gantt.config.font_width_ratio = 7;\n",
       "        gantt.templates.leftside_text = function leftSideTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;left&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "        gantt.templates.rightside_text = function rightSideTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;right&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "        gantt.templates.task_text = function taskTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;center&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "\n",
       "        function getTaskFitValue(task) {\n",
       "            var taskStartPos = gantt.posFromDate(task.start_date),\n",
       "                taskEndPos = gantt.posFromDate(task.end_date);\n",
       "\n",
       "            var width = taskEndPos - taskStartPos;\n",
       "            var textWidth = (task.text || &quot;&quot;).length * gantt.config.font_width_ratio;\n",
       "\n",
       "            if (width &lt; textWidth) {\n",
       "                var ganttLastDate = gantt.getState().max_date;\n",
       "                var ganttEndPos = gantt.posFromDate(ganttLastDate);\n",
       "                if (ganttEndPos - taskEndPos &lt; textWidth) {\n",
       "                    return &quot;left&quot;\n",
       "                } else {\n",
       "                    return &quot;right&quot;\n",
       "                }\n",
       "            } else {\n",
       "                return &quot;center&quot;;\n",
       "            }\n",
       "        }\n",
       "    })();\n",
       "\n",
       "    gantt.templates.task_class = function (start, end, task) {\n",
       "        return task.css_class;\n",
       "    };\n",
       "\n",
       "    gantt.config.readonly = true;\n",
       "\n",
       "    gantt.init(&quot;gantt_here&quot;);\n",
       "\n",
       "    gantt.parse({\n",
       "  &quot;data&quot;: [\n",
       "    {\n",
       "      &quot;id&quot;: 1,\n",
       "      &quot;text&quot;: &quot;Task 1&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;27-03-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;01-04-2023&quot;,\n",
       "      &quot;resource&quot;: &quot;Tester&quot;,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 1&quot;,\n",
       "      &quot;start&quot;: &quot;2023-03-27 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-01 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;40&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 2,\n",
       "      &quot;text&quot;: &quot;Task 2&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;03-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;resource&quot;: &quot;Tester&quot;,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 2&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-03 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;20&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;text&quot;: &quot;Task 4&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;22-04-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 4&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-22 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;100&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;text&quot;: &quot;Task 5&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;24-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 5&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-24 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;50&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 3,\n",
       "      &quot;text&quot;: &quot;Task 3&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 3&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;150&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;text&quot;: &quot;Task 4&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;22-04-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 4&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-22 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;100&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;text&quot;: &quot;Task 5&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;24-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 5&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-24 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;50&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;text&quot;: &quot;Task 7&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 7&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;text&quot;: &quot;Task 8&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 8&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 6,\n",
       "      &quot;text&quot;: &quot;Task 6&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 6&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;32&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;text&quot;: &quot;Task 7&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 7&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;text&quot;: &quot;Task 8&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 8&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    }\n",
       "  ],\n",
       "  &quot;links&quot;: [\n",
       "    {\n",
       "      &quot;id&quot;: 1,\n",
       "      &quot;source&quot;: 1,\n",
       "      &quot;target&quot;: 2,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 2,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 4,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 3,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 5,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 4,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 5,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 6,\n",
       "      &quot;source&quot;: 5,\n",
       "      &quot;target&quot;: 7,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;source&quot;: 7,\n",
       "      &quot;target&quot;: 8,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;source&quot;: 5,\n",
       "      &quot;target&quot;: 7,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 9,\n",
       "      &quot;source&quot;: 7,\n",
       "      &quot;target&quot;: 8,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    }\n",
       "  ]\n",
       "});\n",
       "\n",
       "&lt;/script&gt;\n",
       "&lt;/body&gt;\n",
       "&lt;/html&gt;\n",
       "\" width=\"100%\" height=\"300\" style=\"border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>"
      ],
      "text/plain": [
       "<pjplan.viz.dhtmlx.gantt.DhtmlxGantt at 0x2295f326410>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "DhtmlxGantt(plan, height=300)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Sidebar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<iframe srcdoc=\"&lt;html&gt;\n",
       "&lt;meta charset=&quot;utf-8&quot;&gt;\n",
       "&lt;body&gt;\n",
       "&lt;script src=&quot;https://storage.yandexcloud.net/gymboss-test/gantt/gantt/dhtmlxgantt.js?v=7.1.13&quot;&gt;&lt;/script&gt;\n",
       "&lt;link rel=&quot;stylesheet&quot; href=&quot;https://storage.yandexcloud.net/gymboss-test/gantt/gantt/dhtmlxgantt.css?v=7.1.13&quot;&gt;\n",
       "&lt;style&gt;\n",
       "    html, body {\n",
       "        padding: 0px;\n",
       "        margin: 0px;\n",
       "        height: 100%;\n",
       "    }\n",
       "\n",
       "    .gantt_side_content.gantt_link_crossing {\n",
       "        top:0\n",
       "    }\n",
       "\n",
       "    \n",
       "&lt;/style&gt;\n",
       "&lt;div id=&quot;gantt_here&quot; style=&#x27;width:100%; height:100%;&#x27;&gt;&lt;/div&gt;\n",
       "&lt;script&gt;\n",
       "\n",
       "    gantt.plugins({\n",
       "        marker: true,\n",
       "        grouping: true\n",
       "    });\n",
       "\n",
       "    gantt.ext.zoom.init({\n",
       "        minColumnWidth: 80,\n",
       "        maxColumnWidth: 150,\n",
       "        levels: [\n",
       "            [\n",
       "                {unit: &quot;year&quot;, format: &quot;%Y&quot;, step: 1},\n",
       "                {unit: &quot;month&quot;, format: &quot;%M&quot;, step: 1},\n",
       "            ],\n",
       "            [\n",
       "                {unit: &quot;month&quot;, format: &quot;%M %Y&quot;, step: 1},\n",
       "                {\n",
       "                    unit: &quot;week&quot;, step: 1, format: function (date) {\n",
       "                        var dateToStr = gantt.date.date_to_str(&quot;%d.%m&quot;);\n",
       "                        var endDate = gantt.date.add(date, -6, &quot;day&quot;);\n",
       "                        return dateToStr(date) + &quot; - &quot; + dateToStr(endDate);\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            [\n",
       "                {unit: &quot;month&quot;, format: &quot;%M %y&quot;, step: 1},\n",
       "                {unit: &quot;day&quot;, format: &quot;%d.%m&quot;, step: 1}\n",
       "            ]\n",
       "        ],\n",
       "        useKey: &quot;ctrlKey&quot;,\n",
       "        trigger: &quot;wheel&quot;,\n",
       "        element: function () {\n",
       "            return gantt.$root.querySelector(&quot;.gantt_task&quot;);\n",
       "        }\n",
       "    });\n",
       "\n",
       "    gantt.config.min_column_width = 20;\n",
       "    gantt.config.auto_types = true;\n",
       "\n",
       "    if (true) {\n",
       "        gantt.addMarker({\n",
       "            start_date: new Date(),\n",
       "            css: &quot;today&quot;,\n",
       "        });\n",
       "    }\n",
       "\n",
       "    gantt.config.columns = [{&quot;name&quot;: &quot;text&quot;, &quot;tree&quot;: true, &quot;width&quot;: 200, &quot;resize&quot;: true, &quot;label&quot;: &quot;Name&quot;}];\n",
       "\n",
       "    gantt.config.row_height = 25;\n",
       "\n",
       "    (function () {\n",
       "        gantt.config.font_width_ratio = 7;\n",
       "        gantt.templates.leftside_text = function leftSideTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;left&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "        gantt.templates.rightside_text = function rightSideTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;right&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "        gantt.templates.task_text = function taskTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;center&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "\n",
       "        function getTaskFitValue(task) {\n",
       "            var taskStartPos = gantt.posFromDate(task.start_date),\n",
       "                taskEndPos = gantt.posFromDate(task.end_date);\n",
       "\n",
       "            var width = taskEndPos - taskStartPos;\n",
       "            var textWidth = (task.text || &quot;&quot;).length * gantt.config.font_width_ratio;\n",
       "\n",
       "            if (width &lt; textWidth) {\n",
       "                var ganttLastDate = gantt.getState().max_date;\n",
       "                var ganttEndPos = gantt.posFromDate(ganttLastDate);\n",
       "                if (ganttEndPos - taskEndPos &lt; textWidth) {\n",
       "                    return &quot;left&quot;\n",
       "                } else {\n",
       "                    return &quot;right&quot;\n",
       "                }\n",
       "            } else {\n",
       "                return &quot;center&quot;;\n",
       "            }\n",
       "        }\n",
       "    })();\n",
       "\n",
       "    gantt.templates.task_class = function (start, end, task) {\n",
       "        return task.css_class;\n",
       "    };\n",
       "\n",
       "    gantt.config.readonly = true;\n",
       "\n",
       "    gantt.init(&quot;gantt_here&quot;);\n",
       "\n",
       "    gantt.parse({\n",
       "  &quot;data&quot;: [\n",
       "    {\n",
       "      &quot;id&quot;: 1,\n",
       "      &quot;text&quot;: &quot;Task 1&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;27-03-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;01-04-2023&quot;,\n",
       "      &quot;resource&quot;: &quot;Tester&quot;,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 1&quot;,\n",
       "      &quot;start&quot;: &quot;2023-03-27 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-01 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;40&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 2,\n",
       "      &quot;text&quot;: &quot;Task 2&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;03-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;resource&quot;: &quot;Tester&quot;,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 2&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-03 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;20&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;text&quot;: &quot;Task 4&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;22-04-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 4&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-22 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;100&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;text&quot;: &quot;Task 5&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;24-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 5&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-24 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;50&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 3,\n",
       "      &quot;text&quot;: &quot;Task 3&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 3&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;150&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;text&quot;: &quot;Task 4&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;22-04-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 4&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-22 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;100&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;text&quot;: &quot;Task 5&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;24-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 5&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-24 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;50&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;text&quot;: &quot;Task 7&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 7&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;text&quot;: &quot;Task 8&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 8&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 6,\n",
       "      &quot;text&quot;: &quot;Task 6&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 6&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;32&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;text&quot;: &quot;Task 7&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 7&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;text&quot;: &quot;Task 8&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 8&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    }\n",
       "  ],\n",
       "  &quot;links&quot;: [\n",
       "    {\n",
       "      &quot;id&quot;: 1,\n",
       "      &quot;source&quot;: 1,\n",
       "      &quot;target&quot;: 2,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 2,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 4,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 3,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 5,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 4,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 5,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 6,\n",
       "      &quot;source&quot;: 5,\n",
       "      &quot;target&quot;: 7,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;source&quot;: 7,\n",
       "      &quot;target&quot;: 8,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;source&quot;: 5,\n",
       "      &quot;target&quot;: 7,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 9,\n",
       "      &quot;source&quot;: 7,\n",
       "      &quot;target&quot;: 8,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    }\n",
       "  ]\n",
       "});\n",
       "\n",
       "&lt;/script&gt;\n",
       "&lt;/body&gt;\n",
       "&lt;/html&gt;\n",
       "\" width=\"100%\" height=\"300\" style=\"border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>"
      ],
      "text/plain": [
       "<pjplan.viz.dhtmlx.gantt.DhtmlxGantt at 0x2290f8f4f40>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "DhtmlxGantt(\n",
    "    plan,\n",
    "    height=300,\n",
    "    columns=[\n",
    "        DhtmlxGanttColumn(field='name', width=200, tree=True, label='Name')\n",
    "    ]\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Custom bar styles"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<iframe srcdoc=\"&lt;html&gt;\n",
       "&lt;meta charset=&quot;utf-8&quot;&gt;\n",
       "&lt;body&gt;\n",
       "&lt;script src=&quot;https://storage.yandexcloud.net/gymboss-test/gantt/gantt/dhtmlxgantt.js?v=7.1.13&quot;&gt;&lt;/script&gt;\n",
       "&lt;link rel=&quot;stylesheet&quot; href=&quot;https://storage.yandexcloud.net/gymboss-test/gantt/gantt/dhtmlxgantt.css?v=7.1.13&quot;&gt;\n",
       "&lt;style&gt;\n",
       "    html, body {\n",
       "        padding: 0px;\n",
       "        margin: 0px;\n",
       "        height: 100%;\n",
       "    }\n",
       "\n",
       "    .gantt_side_content.gantt_link_crossing {\n",
       "        top:0\n",
       "    }\n",
       "\n",
       "    .dhtmlx_bar_0{background:red!important;}\n",
       "\n",
       "&lt;/style&gt;\n",
       "&lt;div id=&quot;gantt_here&quot; style=&#x27;width:100%; height:100%;&#x27;&gt;&lt;/div&gt;\n",
       "&lt;script&gt;\n",
       "\n",
       "    gantt.plugins({\n",
       "        marker: true,\n",
       "        grouping: true\n",
       "    });\n",
       "\n",
       "    gantt.ext.zoom.init({\n",
       "        minColumnWidth: 80,\n",
       "        maxColumnWidth: 150,\n",
       "        levels: [\n",
       "            [\n",
       "                {unit: &quot;year&quot;, format: &quot;%Y&quot;, step: 1},\n",
       "                {unit: &quot;month&quot;, format: &quot;%M&quot;, step: 1},\n",
       "            ],\n",
       "            [\n",
       "                {unit: &quot;month&quot;, format: &quot;%M %Y&quot;, step: 1},\n",
       "                {\n",
       "                    unit: &quot;week&quot;, step: 1, format: function (date) {\n",
       "                        var dateToStr = gantt.date.date_to_str(&quot;%d.%m&quot;);\n",
       "                        var endDate = gantt.date.add(date, -6, &quot;day&quot;);\n",
       "                        return dateToStr(date) + &quot; - &quot; + dateToStr(endDate);\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            [\n",
       "                {unit: &quot;month&quot;, format: &quot;%M %y&quot;, step: 1},\n",
       "                {unit: &quot;day&quot;, format: &quot;%d.%m&quot;, step: 1}\n",
       "            ]\n",
       "        ],\n",
       "        useKey: &quot;ctrlKey&quot;,\n",
       "        trigger: &quot;wheel&quot;,\n",
       "        element: function () {\n",
       "            return gantt.$root.querySelector(&quot;.gantt_task&quot;);\n",
       "        }\n",
       "    });\n",
       "\n",
       "    gantt.config.min_column_width = 20;\n",
       "    gantt.config.auto_types = true;\n",
       "\n",
       "    if (true) {\n",
       "        gantt.addMarker({\n",
       "            start_date: new Date(),\n",
       "            css: &quot;today&quot;,\n",
       "        });\n",
       "    }\n",
       "\n",
       "    gantt.config.columns = [];\n",
       "\n",
       "    gantt.config.row_height = 25;\n",
       "\n",
       "    (function () {\n",
       "        gantt.config.font_width_ratio = 7;\n",
       "        gantt.templates.leftside_text = function leftSideTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;left&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "        gantt.templates.rightside_text = function rightSideTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;right&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "        gantt.templates.task_text = function taskTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;center&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "\n",
       "        function getTaskFitValue(task) {\n",
       "            var taskStartPos = gantt.posFromDate(task.start_date),\n",
       "                taskEndPos = gantt.posFromDate(task.end_date);\n",
       "\n",
       "            var width = taskEndPos - taskStartPos;\n",
       "            var textWidth = (task.text || &quot;&quot;).length * gantt.config.font_width_ratio;\n",
       "\n",
       "            if (width &lt; textWidth) {\n",
       "                var ganttLastDate = gantt.getState().max_date;\n",
       "                var ganttEndPos = gantt.posFromDate(ganttLastDate);\n",
       "                if (ganttEndPos - taskEndPos &lt; textWidth) {\n",
       "                    return &quot;left&quot;\n",
       "                } else {\n",
       "                    return &quot;right&quot;\n",
       "                }\n",
       "            } else {\n",
       "                return &quot;center&quot;;\n",
       "            }\n",
       "        }\n",
       "    })();\n",
       "\n",
       "    gantt.templates.task_class = function (start, end, task) {\n",
       "        return task.css_class;\n",
       "    };\n",
       "\n",
       "    gantt.config.readonly = true;\n",
       "\n",
       "    gantt.init(&quot;gantt_here&quot;);\n",
       "\n",
       "    gantt.parse({\n",
       "  &quot;data&quot;: [\n",
       "    {\n",
       "      &quot;id&quot;: 1,\n",
       "      &quot;text&quot;: &quot;Task 1&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;27-03-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;01-04-2023&quot;,\n",
       "      &quot;resource&quot;: &quot;Tester&quot;,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: &quot;dhtmlx_bar_0&quot;,\n",
       "      &quot;name&quot;: &quot;Task 1&quot;,\n",
       "      &quot;start&quot;: &quot;2023-03-27 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-01 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;40&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;,\n",
       "      &quot;gantt_bar_style&quot;: &quot;{&#x27;background&#x27;: &#x27;red&#x27;}&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 2,\n",
       "      &quot;text&quot;: &quot;Task 2&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;03-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;resource&quot;: &quot;Tester&quot;,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: &quot;dhtmlx_bar_0&quot;,\n",
       "      &quot;name&quot;: &quot;Task 2&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-03 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;20&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;,\n",
       "      &quot;gantt_bar_style&quot;: &quot;{&#x27;background&#x27;: &#x27;red&#x27;}&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;text&quot;: &quot;Task 4&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;22-04-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 4&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-22 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;100&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;text&quot;: &quot;Task 5&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;24-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 5&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-24 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;50&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 3,\n",
       "      &quot;text&quot;: &quot;Task 3&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 3&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;150&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;text&quot;: &quot;Task 4&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;22-04-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 4&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-22 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;100&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;text&quot;: &quot;Task 5&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;24-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 5&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-24 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;50&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;text&quot;: &quot;Task 7&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 7&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;text&quot;: &quot;Task 8&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 8&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 6,\n",
       "      &quot;text&quot;: &quot;Task 6&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 6&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;32&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;text&quot;: &quot;Task 7&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 7&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;text&quot;: &quot;Task 8&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 8&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    }\n",
       "  ],\n",
       "  &quot;links&quot;: [\n",
       "    {\n",
       "      &quot;id&quot;: 1,\n",
       "      &quot;source&quot;: 1,\n",
       "      &quot;target&quot;: 2,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 2,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 4,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 3,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 5,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 4,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 5,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 6,\n",
       "      &quot;source&quot;: 5,\n",
       "      &quot;target&quot;: 7,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;source&quot;: 7,\n",
       "      &quot;target&quot;: 8,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;source&quot;: 5,\n",
       "      &quot;target&quot;: 7,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 9,\n",
       "      &quot;source&quot;: 7,\n",
       "      &quot;target&quot;: 8,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    }\n",
       "  ]\n",
       "});\n",
       "\n",
       "&lt;/script&gt;\n",
       "&lt;/body&gt;\n",
       "&lt;/html&gt;\n",
       "\" width=\"100%\" height=\"300\" style=\"border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>"
      ],
      "text/plain": [
       "<pjplan.viz.dhtmlx.gantt.DhtmlxGantt at 0x2290f8f44f0>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p = plan.clone()\n",
    "p(resource='Tester').gantt_bar_style = {\n",
    "    'background': 'red'\n",
    "}\n",
    "DhtmlxGantt(p, height=300)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Collapse children"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<iframe srcdoc=\"&lt;html&gt;\n",
       "&lt;meta charset=&quot;utf-8&quot;&gt;\n",
       "&lt;body&gt;\n",
       "&lt;script src=&quot;https://storage.yandexcloud.net/gymboss-test/gantt/gantt/dhtmlxgantt.js?v=7.1.13&quot;&gt;&lt;/script&gt;\n",
       "&lt;link rel=&quot;stylesheet&quot; href=&quot;https://storage.yandexcloud.net/gymboss-test/gantt/gantt/dhtmlxgantt.css?v=7.1.13&quot;&gt;\n",
       "&lt;style&gt;\n",
       "    html, body {\n",
       "        padding: 0px;\n",
       "        margin: 0px;\n",
       "        height: 100%;\n",
       "    }\n",
       "\n",
       "    .gantt_side_content.gantt_link_crossing {\n",
       "        top:0\n",
       "    }\n",
       "\n",
       "    \n",
       "&lt;/style&gt;\n",
       "&lt;div id=&quot;gantt_here&quot; style=&#x27;width:100%; height:100%;&#x27;&gt;&lt;/div&gt;\n",
       "&lt;script&gt;\n",
       "\n",
       "    gantt.plugins({\n",
       "        marker: true,\n",
       "        grouping: true\n",
       "    });\n",
       "\n",
       "    gantt.ext.zoom.init({\n",
       "        minColumnWidth: 80,\n",
       "        maxColumnWidth: 150,\n",
       "        levels: [\n",
       "            [\n",
       "                {unit: &quot;year&quot;, format: &quot;%Y&quot;, step: 1},\n",
       "                {unit: &quot;month&quot;, format: &quot;%M&quot;, step: 1},\n",
       "            ],\n",
       "            [\n",
       "                {unit: &quot;month&quot;, format: &quot;%M %Y&quot;, step: 1},\n",
       "                {\n",
       "                    unit: &quot;week&quot;, step: 1, format: function (date) {\n",
       "                        var dateToStr = gantt.date.date_to_str(&quot;%d.%m&quot;);\n",
       "                        var endDate = gantt.date.add(date, -6, &quot;day&quot;);\n",
       "                        return dateToStr(date) + &quot; - &quot; + dateToStr(endDate);\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            [\n",
       "                {unit: &quot;month&quot;, format: &quot;%M %y&quot;, step: 1},\n",
       "                {unit: &quot;day&quot;, format: &quot;%d.%m&quot;, step: 1}\n",
       "            ]\n",
       "        ],\n",
       "        useKey: &quot;ctrlKey&quot;,\n",
       "        trigger: &quot;wheel&quot;,\n",
       "        element: function () {\n",
       "            return gantt.$root.querySelector(&quot;.gantt_task&quot;);\n",
       "        }\n",
       "    });\n",
       "\n",
       "    gantt.config.min_column_width = 20;\n",
       "    gantt.config.auto_types = true;\n",
       "\n",
       "    if (true) {\n",
       "        gantt.addMarker({\n",
       "            start_date: new Date(),\n",
       "            css: &quot;today&quot;,\n",
       "        });\n",
       "    }\n",
       "\n",
       "    gantt.config.columns = [{&quot;name&quot;: &quot;text&quot;, &quot;tree&quot;: true, &quot;width&quot;: 200, &quot;resize&quot;: true, &quot;label&quot;: &quot;Name&quot;}];\n",
       "\n",
       "    gantt.config.row_height = 25;\n",
       "\n",
       "    (function () {\n",
       "        gantt.config.font_width_ratio = 7;\n",
       "        gantt.templates.leftside_text = function leftSideTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;left&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "        gantt.templates.rightside_text = function rightSideTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;right&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "        gantt.templates.task_text = function taskTextTemplate(start, end, task) {\n",
       "            if (getTaskFitValue(task) === &quot;center&quot;) {\n",
       "                return task.text;\n",
       "            }\n",
       "            return &quot;&quot;;\n",
       "        };\n",
       "\n",
       "        function getTaskFitValue(task) {\n",
       "            var taskStartPos = gantt.posFromDate(task.start_date),\n",
       "                taskEndPos = gantt.posFromDate(task.end_date);\n",
       "\n",
       "            var width = taskEndPos - taskStartPos;\n",
       "            var textWidth = (task.text || &quot;&quot;).length * gantt.config.font_width_ratio;\n",
       "\n",
       "            if (width &lt; textWidth) {\n",
       "                var ganttLastDate = gantt.getState().max_date;\n",
       "                var ganttEndPos = gantt.posFromDate(ganttLastDate);\n",
       "                if (ganttEndPos - taskEndPos &lt; textWidth) {\n",
       "                    return &quot;left&quot;\n",
       "                } else {\n",
       "                    return &quot;right&quot;\n",
       "                }\n",
       "            } else {\n",
       "                return &quot;center&quot;;\n",
       "            }\n",
       "        }\n",
       "    })();\n",
       "\n",
       "    gantt.templates.task_class = function (start, end, task) {\n",
       "        return task.css_class;\n",
       "    };\n",
       "\n",
       "    gantt.config.readonly = true;\n",
       "\n",
       "    gantt.init(&quot;gantt_here&quot;);\n",
       "\n",
       "    gantt.parse({\n",
       "  &quot;data&quot;: [\n",
       "    {\n",
       "      &quot;id&quot;: 1,\n",
       "      &quot;text&quot;: &quot;Task 1&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;27-03-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;01-04-2023&quot;,\n",
       "      &quot;resource&quot;: &quot;Tester&quot;,\n",
       "      &quot;open&quot;: false,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 1&quot;,\n",
       "      &quot;start&quot;: &quot;2023-03-27 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-01 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;40&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;,\n",
       "      &quot;gantt_open&quot;: &quot;False&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 2,\n",
       "      &quot;text&quot;: &quot;Task 2&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;03-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;resource&quot;: &quot;Tester&quot;,\n",
       "      &quot;open&quot;: false,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 2&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-03 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;20&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;,\n",
       "      &quot;gantt_open&quot;: &quot;False&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;text&quot;: &quot;Task 4&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;22-04-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 4&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-22 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;100&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;text&quot;: &quot;Task 5&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;24-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 5&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-24 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;50&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 3,\n",
       "      &quot;text&quot;: &quot;Task 3&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: false,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 3&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;150&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;,\n",
       "      &quot;gantt_open&quot;: &quot;False&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;text&quot;: &quot;Task 4&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;05-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;22-04-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 4&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-05 12:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-04-22 00:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;100&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;text&quot;: &quot;Task 5&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;24-04-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 3,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 5&quot;,\n",
       "      &quot;start&quot;: &quot;2023-04-24 00:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;50&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;text&quot;: &quot;Task 7&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 7&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;text&quot;: &quot;Task 8&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 8&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 6,\n",
       "      &quot;text&quot;: &quot;Task 6&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: false,\n",
       "      &quot;parent&quot;: 0,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 6&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;32&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;,\n",
       "      &quot;gantt_open&quot;: &quot;False&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;text&quot;: &quot;Task 7&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;02-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 7&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-02 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;text&quot;: &quot;Task 8&quot;,\n",
       "      &quot;type&quot;: &quot;task&quot;,\n",
       "      &quot;start_date&quot;: &quot;04-05-2023&quot;,\n",
       "      &quot;end_date&quot;: &quot;08-05-2023&quot;,\n",
       "      &quot;resource&quot;: null,\n",
       "      &quot;open&quot;: &quot;true&quot;,\n",
       "      &quot;parent&quot;: 6,\n",
       "      &quot;progress&quot;: 0.0,\n",
       "      &quot;css_class&quot;: null,\n",
       "      &quot;name&quot;: &quot;Task 8&quot;,\n",
       "      &quot;start&quot;: &quot;2023-05-04 06:00:00&quot;,\n",
       "      &quot;end&quot;: &quot;2023-05-08 06:00:00&quot;,\n",
       "      &quot;milestone&quot;: &quot;False&quot;,\n",
       "      &quot;estimate&quot;: &quot;16&quot;,\n",
       "      &quot;spent&quot;: &quot;0&quot;\n",
       "    }\n",
       "  ],\n",
       "  &quot;links&quot;: [\n",
       "    {\n",
       "      &quot;id&quot;: 1,\n",
       "      &quot;source&quot;: 1,\n",
       "      &quot;target&quot;: 2,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 2,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 4,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 3,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 5,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 4,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 4,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 5,\n",
       "      &quot;source&quot;: 2,\n",
       "      &quot;target&quot;: 5,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 6,\n",
       "      &quot;source&quot;: 5,\n",
       "      &quot;target&quot;: 7,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 7,\n",
       "      &quot;source&quot;: 7,\n",
       "      &quot;target&quot;: 8,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 8,\n",
       "      &quot;source&quot;: 5,\n",
       "      &quot;target&quot;: 7,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    },\n",
       "    {\n",
       "      &quot;id&quot;: 9,\n",
       "      &quot;source&quot;: 7,\n",
       "      &quot;target&quot;: 8,\n",
       "      &quot;type&quot;: &quot;0&quot;\n",
       "    }\n",
       "  ]\n",
       "});\n",
       "\n",
       "&lt;/script&gt;\n",
       "&lt;/body&gt;\n",
       "&lt;/html&gt;\n",
       "\" width=\"100%\" height=\"300\" style=\"border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>"
      ],
      "text/plain": [
       "<pjplan.viz.dhtmlx.gantt.DhtmlxGantt at 0x2290f94ba00>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p = plan.clone()\n",
    "p(parent_id=0).gantt_open=False\n",
    "DhtmlxGantt(p, height=300, columns=[DhtmlxGanttColumn(field='name', width=200, tree=True, label='Name')])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
