{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "start_time": "2023-04-06T09:23:04.104417Z",
     "end_time": "2023-04-06T09:23:04.114805Z"
    }
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.append('../../src')\n",
    "from pjplan import Task, WBS, MermaidNetwork"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "### Sample project"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "data": {
      "text/plain": "\u001B[92mID   NAME    RESOURCE   ESTIMATE   SPENT   START   END   PREDECESSORS \u001B[0m\n\u001B[94m     Task 1  Tester     -          -       -       -     []           \u001B[0m\n\u001B[94m     Task 2  Tester     20         -       -       -     [1]          \u001B[0m\n\u001B[94m     Task 3  -          20         -       -       -     [1]          \u001B[0m\n\u001B[94m     Task 4  -          20         -       -       -     [3]          \u001B[0m"
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "with WBS() as prj:\n",
    "    prj // Task(1, 'Task 1', resource='Tester')\n",
    "    prj // Task(2, 'Task 2', predecessors=[prj[1]], estimate=20, resource='Tester')\n",
    "    prj // Task(3, 'Task 3', predecessors=[prj[1]], estimate=20)\n",
    "    prj // Task(4, 'Task 4', predecessors=[prj[3]], estimate=20)\n",
    "\n",
    "prj"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "start_time": "2023-04-06T09:23:04.116805Z",
     "end_time": "2023-04-06T09:23:04.131807Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### Simple diagram"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "data": {
      "text/plain": "<pjplan.viz.mermaid.network.MermaidNetwork at 0x2b9ef8e9c00>",
      "text/html": "<iframe srcdoc=\"&lt;html&gt;\n&lt;meta charset=&quot;UTF-8&quot;&gt;\n&lt;body&gt;\n&lt;div class=&quot;mermaid&quot;&gt;\nflowchart LR\n  0((Start)) --&gt; 1{{Task 1}}\n  1{{Task 1}} --&gt; 2{{Task 2}}\n  1{{Task 1}} --&gt; 3{{Task 3}}\n  3{{Task 3}} --&gt; 4{{Task 4}}\n\n&lt;/div&gt;\n\n&lt;script src=&quot;https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js&quot;&gt;&lt;/script&gt;\n&lt;script&gt;\n    mermaid.ganttConfig = {\n        mirrorActor: true\n    }\n    mermaid.initialize({\n        startOnLoad: true\n    });\n&lt;/script&gt;\n&lt;/body&gt;\n&lt;/html&gt;\" width=\"100%\" height=\"160\" style=\"border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>"
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "MermaidNetwork(prj, height=160)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "start_time": "2023-04-06T09:23:04.132807Z",
     "end_time": "2023-04-06T09:23:04.176980Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### Custom bar styles"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [
    {
     "data": {
      "text/plain": "<pjplan.viz.mermaid.network.MermaidNetwork at 0x2b9ef99d8d0>",
      "text/html": "<iframe srcdoc=\"&lt;html&gt;\n&lt;meta charset=&quot;UTF-8&quot;&gt;\n&lt;body&gt;\n&lt;div class=&quot;mermaid&quot;&gt;\nflowchart LR\n  0((Start)) --&gt; 1{{Task 1}}\n  1{{Task 1}} --&gt; 2{{Task 2}}\n  1{{Task 1}} --&gt; 3{{Task 3}}\n  3{{Task 3}} --&gt; 4{{Task 4}}\nstyle 1 fill:#A1FB8E,stroke:#333,stroke-width:4px\nstyle 2 fill:#A1FB8E,stroke:#333,stroke-width:4px\n\n&lt;/div&gt;\n\n&lt;script src=&quot;https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js&quot;&gt;&lt;/script&gt;\n&lt;script&gt;\n    mermaid.ganttConfig = {\n        mirrorActor: true\n    }\n    mermaid.initialize({\n        startOnLoad: true\n    });\n&lt;/script&gt;\n&lt;/body&gt;\n&lt;/html&gt;\" width=\"100%\" height=\"160\" style=\"border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>"
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Change bar style for tasks with resource='Tester'\n",
    "prj.tasks(resource='Tester').network_bar_style={\n",
    "    'fill':'#A1FB8E',\n",
    "    'stroke':'#333',\n",
    "    'stroke-width':'4px'\n",
    "}\n",
    "MermaidNetwork(prj, height=160)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "start_time": "2023-04-06T09:23:04.148803Z",
     "end_time": "2023-04-06T09:23:04.176980Z"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
