{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "19033da2-bedb-4ef2-81af-5aec1fdff715",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 画图不出，执行一下语句后，在返回之前的 tab，再次执行画图即可\n",
    "\n",
    "确定当前环境是 jupyterlab，而不是 notebook\n",
    "\n",
    "如果还不能解决，参照官方的方法尝试\n",
    "\n",
    "https://pyecharts.org/#/zh-cn/notebook?id=jupyter-lab\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0b4a1332-055f-4cca-b3f5-a8309c8b7d37",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-11-13T07:40:24.345934Z",
     "iopub.status.busy": "2022-11-13T07:40:24.345776Z",
     "iopub.status.idle": "2022-11-13T07:40:24.405570Z",
     "shell.execute_reply": "2022-11-13T07:40:24.405175Z",
     "shell.execute_reply.started": "2022-11-13T07:40:24.345892Z"
    },
    "pycharm": {
     "name": "#%%\n"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "application/javascript": [
       "new Promise(function(resolve, reject) {\n",
       "    var script = document.createElement(\"script\");\n",
       "    script.onload = resolve;\n",
       "    script.onerror = reject;\n",
       "    script.src = \"https://assets.pyecharts.org/assets/echarts.min.js\";\n",
       "    document.head.appendChild(script);\n",
       "}).then(() => {\n",
       "\n",
       "});"
      ],
      "text/plain": [
       "<pyecharts.render.display.Javascript at 0x7f511ccf1c50>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.globals import CurrentConfig, NotebookType\n",
    "\n",
    "CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB\n",
    "\n",
    "from pyecharts.charts import Kline, Bar, Grid, Scatter, Line\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.globals import ThemeType\n",
    "\n",
    "Kline().load_javascript()\n",
    "Bar().load_javascript()\n",
    "Grid().load_javascript()\n",
    "Scatter().load_javascript()\n",
    "Line().load_javascript()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "23f2ba09-89bb-4ce8-8b31-36c4ced3ba4c",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "## 测试画图是否ok\n",
    "line = (\n",
    "    Line(init_opts=opts.InitOpts(theme=ThemeType.WESTEROS))\n",
    "        .add_xaxis(['衬衫', '羊毛衫', '雪绒衫', '裤子', '高跟鞋', '袜子'])\n",
    "        .add_yaxis('商家A', [5, 20, 36, 10, 75, 90])\n",
    "        .add_yaxis('商家B', [15, 6, 45, 20, 35, 66])\n",
    "        .set_global_opts(title_opts=opts.TitleOpts(title='主标题', subtitle='副标题'))\n",
    ")\n",
    "line.render_notebook()"
   ]
  }
 ],
 "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.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
