{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\artem\\AppData\\Local\\Temp\\ipykernel_17612\\3504232214.py:5: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display\n",
      "  from IPython.core.display import display, HTML\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "from datetime import datetime\n",
    "sys.path.append('../../src')\n",
    "from pjplan import Task, DefaultScheduler, WBS, DhtmlxTemplate, DhtmlxColumn, MermaidGanttTemplate\n",
    "from IPython.core.display import display, HTML"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "with WBS('Проект') as prj:\n",
    "    prj // Task(2, 'Задача 1', estimate=40, spent=20, resource='Tester')\n",
    "    prj // Task(3, 'Задача 2', predecessors=[prj(2)], estimate=20, resource='Tester')\n",
    "    with prj // Task(4, 'Задача 4') as t:\n",
    "        t // Task(5, 'Задача 5', predecessors=[prj(3)], estimate=100)\n",
    "        t // Task(6, 'Задача 6', predecessors=[prj(3)], estimate=50)\n",
    "    with prj // Task(7, 'Задача 7') as t:\n",
    "        t // Task(8, 'Задача 8', predecessors=[prj(6)], estimate=16)\n",
    "        t // Task(9, 'Задача 9', predecessors=[prj(6)], estimate=16)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "plan, usage = DefaultScheduler(datetime.now()).calc(prj)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <iframe\n",
       "            width=\"100%\"\n",
       "            height=\"500\"\n",
       "            src=\"<html><body><style>\n",
       "    \n",
       "</style>\n",
       "\n",
       "<div class=\"mermaid\">\n",
       "    gantt\n",
       "  dateFormat DD.MM.YYYY\n",
       "  title Проект\n",
       "    Задача 1:  id_2, 27.03.2023, 29.03.2023\n",
       "    Задача 2:  id_3, 29.03.2023, 01.04.2023\n",
       "    Задача 4:  id_4, 03.04.2023, 27.04.2023\n",
       "    Задача 5:  id_5, 03.04.2023, 19.04.2023\n",
       "    Задача 6:  id_6, 19.04.2023, 27.04.2023\n",
       "    Задача 7:  id_7, 27.04.2023, 03.05.2023\n",
       "    Задача 8:  id_8, 27.04.2023, 01.05.2023\n",
       "    Задача 9:  id_9, 01.05.2023, 03.05.2023\n",
       "\n",
       "</div>\n",
       "\n",
       "<script src=\"https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js\"></script>\n",
       "<script>\n",
       "    mermaid.ganttConfig = {\n",
       "        mirrorActor: true\n",
       "    }\n",
       "    mermaid.initialize({\n",
       "        startOnLoad: true\n",
       "    });\n",
       "</script>\n",
       "</body></html>\"\n",
       "            frameborder=\"0\"\n",
       "            allowfullscreen\n",
       "            \n",
       "        ></iframe>\n",
       "        "
      ],
      "text/plain": [
       "<IPython.lib.display.IFrame at 0x2c0b68d7c40>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from IPython.lib.display import IFrame\n",
    "\n",
    "gantt = MermaidGanttTemplate(plan)\n",
    "display(IFrame(src='<html><body>' + gantt.to_string() + '</body></html>', width=\"100%\", height=500))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "MermaidGanttTemplate(plan).to_string()\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {
      "text/html": {
       "isolated": true
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%html --isolated\n",
    "MermaidGanttTemplate(plan).to_string()"
   ]
  }
 ],
 "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
}
