Files
jupyter/户外运动.ipynb
2021-10-09 15:12:24 +08:00

1355 lines
49 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import pymysql\n",
"import pyecharts\n",
"from datetime import datetime\n",
"\n",
"db = pymysql.connect(\"localhost\",\"songyi\",\"yylzs\",\"mydata\" )\n",
"cursor = db.cursor()\n",
"item_id =1\n",
"per_id = 1\n",
"list_date = []\n",
"dict_tar = {}\n",
"dict_det = {}\n",
"dict_date = {}\n",
"## 获取项目信息\n",
"sql = \"select a.id,a.name,a.unit from sports_target as a,sports_item_target as b where b.item_id =%s and a.id =b.target_id\"\n",
"cursor.execute(sql, (item_id))\n",
"results = cursor.fetchall()\n",
"for result in results:\n",
" dict_tar[result[0]] = [result[1],result[2]]\n",
"## 获取运动记录信息\n",
"sql = \"select id,re_date from sports_record where item_id =%s and person_id =%s order by re_date\"\n",
"cursor.execute(sql, (item_id,per_id))\n",
"results = cursor.fetchall()\n",
"for result in results:\n",
" list_date.append(result[0])\n",
" dict_date[result[0]] = result[1].strftime(\"%Y-%m-%d\")\n",
"s_date = '' \n",
"sql = \"select rec_id_id,target_id_id,value from sports_detail where rec_id_id in {}\".format(tuple(list_date))\n",
"cursor.execute(sql)\n",
"results = cursor.fetchall()\n",
"for s in list_date:\n",
" dict_det[dict_date[s]] = {}\n",
"for result in results:\n",
" s = result[0]\n",
" dict_det[dict_date[s]][result[1]] = result[2]\n",
"#print(dict_det)\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"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 0x7fd1881d60d0>"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from pyecharts.globals import CurrentConfig, NotebookType\n",
"CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB\n",
"from pyecharts import options as opts\n",
"from pyecharts.charts import Bar,Line\n",
"import pyecharts.options as opts\n",
"x_data = []\n",
"y_data1 = []\n",
"y_data2 = []\n",
"y_data3 = []\n",
"y_data4 = []\n",
"for key,value in dict_det.items():\n",
" x_data.append(key)\n",
" y_data1.append(value[8])\n",
" y_data2.append(value[9])\n",
" y_data3.append(value[4])\n",
" y_data4.append(value[5])\n",
"bar = (\n",
" Bar()\n",
" .add_xaxis(x_data)\n",
" .add_yaxis(\"平均心率\", y_data1,label_opts=opts.LabelOpts(is_show=False),gap=\"0%\")\n",
" .add_yaxis(\"最大心率\", y_data2,label_opts=opts.LabelOpts(is_show=False),gap=\"0%\") \n",
" .add_yaxis(\"平均步频\", y_data4,label_opts=opts.LabelOpts(is_show=False),gap=\"0%\")\n",
" .extend_axis(\n",
" yaxis=opts.AxisOpts(\n",
" name=\"平均速度\",\n",
" type_=\"value\",\n",
" min_=min(y_data3),\n",
" max_=max(y_data3),\n",
" interval=(max(y_data3)-min(y_data3))/5,\n",
" axislabel_opts=opts.LabelOpts(formatter=\"{value} km/h\"),\n",
" )\n",
" )\n",
" .set_global_opts(\n",
" tooltip_opts=opts.TooltipOpts(\n",
" is_show=True, trigger=\"axis\", axis_pointer_type=\"cross\"\n",
" ),\n",
" xaxis_opts=opts.AxisOpts(\n",
" type_=\"category\",\n",
" axispointer_opts=opts.AxisPointerOpts(is_show=True, type_=\"shadow\"),\n",
" ),\n",
" yaxis_opts=opts.AxisOpts(\n",
" name=\"心率\",\n",
" type_=\"value\",\n",
" min_=0,\n",
" max_=180,\n",
" interval=20,\n",
" axislabel_opts=opts.LabelOpts(formatter=\"{value} 次/分钟\"),\n",
" axistick_opts=opts.AxisTickOpts(is_show=True),\n",
" splitline_opts=opts.SplitLineOpts(is_show=True),\n",
" ),\n",
" )\n",
" .set_global_opts(title_opts=opts.TitleOpts(title=\"运动心率\", subtitle=\"户外运动\"),)\n",
")\n",
"line = (\n",
" Line()\n",
" .add_xaxis(xaxis_data=x_data)\n",
" .add_yaxis(\n",
" series_name=\"平均速度\",\n",
" yaxis_index=1,\n",
" y_axis=y_data3,\n",
" label_opts=opts.LabelOpts(is_show=False),\n",
" )\n",
")\n",
"\n",
"bar.overlap(line).load_javascript()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<!DOCTYPE html>\n",
"<html>\n",
"<head>\n",
" <meta charset=\"UTF-8\">\n",
"</head>\n",
"<body>\n",
" <div id=\"3c959869b1fc4fc6b8f9aedf18b9f8b1\" class=\"chart-container\" style=\"width:900px; height:500px;\"></div>\n",
" <script>\n",
" var chart_3c959869b1fc4fc6b8f9aedf18b9f8b1 = echarts.init(\n",
" document.getElementById('3c959869b1fc4fc6b8f9aedf18b9f8b1'), 'white', {renderer: 'canvas'});\n",
" var option_3c959869b1fc4fc6b8f9aedf18b9f8b1 = {\n",
" \"animation\": true,\n",
" \"animationThreshold\": 2000,\n",
" \"animationDuration\": 1000,\n",
" \"animationEasing\": \"cubicOut\",\n",
" \"animationDelay\": 0,\n",
" \"animationDurationUpdate\": 300,\n",
" \"animationEasingUpdate\": \"cubicOut\",\n",
" \"animationDelayUpdate\": 0,\n",
" \"color\": [\n",
" \"#c23531\",\n",
" \"#2f4554\",\n",
" \"#61a0a8\",\n",
" \"#d48265\",\n",
" \"#749f83\",\n",
" \"#ca8622\",\n",
" \"#bda29a\",\n",
" \"#6e7074\",\n",
" \"#546570\",\n",
" \"#c4ccd3\",\n",
" \"#f05b72\",\n",
" \"#ef5b9c\",\n",
" \"#f47920\",\n",
" \"#905a3d\",\n",
" \"#fab27b\",\n",
" \"#2a5caa\",\n",
" \"#444693\",\n",
" \"#726930\",\n",
" \"#b2d235\",\n",
" \"#6d8346\",\n",
" \"#ac6767\",\n",
" \"#1d953f\",\n",
" \"#6950a1\",\n",
" \"#918597\"\n",
" ],\n",
" \"series\": [\n",
" {\n",
" \"type\": \"bar\",\n",
" \"name\": \"\\u5e73\\u5747\\u5fc3\\u7387\",\n",
" \"data\": [\n",
" 155.00,\n",
" 142.00,\n",
" 130.00,\n",
" 133.00,\n",
" 131.00,\n",
" 132.00,\n",
" 132.00,\n",
" 151.00,\n",
" 152.00,\n",
" 149.00,\n",
" 133.00,\n",
" 138.00,\n",
" 132.00,\n",
" 134.00,\n",
" 134.00,\n",
" 150.00,\n",
" 142.00\n",
" ],\n",
" \"barCategoryGap\": \"20%\",\n",
" \"barGap\": \"0%\",\n",
" \"label\": {\n",
" \"show\": false,\n",
" \"position\": \"top\",\n",
" \"margin\": 8\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"bar\",\n",
" \"name\": \"\\u6700\\u5927\\u5fc3\\u7387\",\n",
" \"data\": [\n",
" 179.00,\n",
" 178.00,\n",
" 141.00,\n",
" 147.00,\n",
" 140.00,\n",
" 141.00,\n",
" 140.00,\n",
" 162.00,\n",
" 171.00,\n",
" 173.00,\n",
" 144.00,\n",
" 175.00,\n",
" 146.00,\n",
" 155.00,\n",
" 167.00,\n",
" 182.00,\n",
" 169.00\n",
" ],\n",
" \"barCategoryGap\": \"20%\",\n",
" \"barGap\": \"0%\",\n",
" \"label\": {\n",
" \"show\": false,\n",
" \"position\": \"top\",\n",
" \"margin\": 8\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"bar\",\n",
" \"name\": \"\\u5e73\\u5747\\u6b65\\u9891\",\n",
" \"data\": [\n",
" 167.00,\n",
" 163.00,\n",
" 169.00,\n",
" 169.00,\n",
" 170.00,\n",
" 172.00,\n",
" 171.00,\n",
" 175.00,\n",
" 177.00,\n",
" 173.00,\n",
" 174.00,\n",
" 171.00,\n",
" 174.00,\n",
" 175.00,\n",
" 176.00,\n",
" 171.00,\n",
" 172.00\n",
" ],\n",
" \"barCategoryGap\": \"20%\",\n",
" \"barGap\": \"0%\",\n",
" \"label\": {\n",
" \"show\": false,\n",
" \"position\": \"top\",\n",
" \"margin\": 8\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"line\",\n",
" \"name\": \"\\u5e73\\u5747\\u901f\\u5ea6\",\n",
" \"connectNulls\": false,\n",
" \"yAxisIndex\": 1,\n",
" \"symbolSize\": 4,\n",
" \"showSymbol\": true,\n",
" \"smooth\": false,\n",
" \"step\": false,\n",
" \"data\": [\n",
" [\n",
" \"2020-04-04\",\n",
" 8.11\n",
" ],\n",
" [\n",
" \"2020-06-19\",\n",
" 7.53\n",
" ],\n",
" [\n",
" \"2020-06-20\",\n",
" 7.57\n",
" ],\n",
" [\n",
" \"2020-06-21\",\n",
" 7.68\n",
" ],\n",
" [\n",
" \"2020-06-22\",\n",
" 7.64\n",
" ],\n",
" [\n",
" \"2020-06-23\",\n",
" 7.86\n",
" ],\n",
" [\n",
" \"2020-06-24\",\n",
" 7.67\n",
" ],\n",
" [\n",
" \"2020-06-26\",\n",
" 8.89\n",
" ],\n",
" [\n",
" \"2020-06-27\",\n",
" 8.84\n",
" ],\n",
" [\n",
" \"2020-06-28\",\n",
" 7.86\n",
" ],\n",
" [\n",
" \"2020-06-29\",\n",
" 7.93\n",
" ],\n",
" [\n",
" \"2020-06-30\",\n",
" 7.73\n",
" ],\n",
" [\n",
" \"2020-07-01\",\n",
" 8.11\n",
" ],\n",
" [\n",
" \"2020-07-02\",\n",
" 7.94\n",
" ],\n",
" [\n",
" \"2020-07-03\",\n",
" 8.06\n",
" ],\n",
" [\n",
" \"2020-07-06\",\n",
" 7.61\n",
" ],\n",
" [\n",
" \"2020-07-07\",\n",
" 8.03\n",
" ]\n",
" ],\n",
" \"hoverAnimation\": true,\n",
" \"label\": {\n",
" \"show\": false,\n",
" \"position\": \"top\",\n",
" \"margin\": 8\n",
" },\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\"\n",
" },\n",
" \"areaStyle\": {\n",
" \"opacity\": 0\n",
" },\n",
" \"zlevel\": 0,\n",
" \"z\": 0\n",
" },\n",
" {\n",
" \"type\": \"line\",\n",
" \"name\": \"\\u5e73\\u5747\\u901f\\u5ea6\",\n",
" \"connectNulls\": false,\n",
" \"yAxisIndex\": 1,\n",
" \"symbolSize\": 4,\n",
" \"showSymbol\": true,\n",
" \"smooth\": false,\n",
" \"step\": false,\n",
" \"data\": [\n",
" [\n",
" \"2020-04-04\",\n",
" 8.11\n",
" ],\n",
" [\n",
" \"2020-06-19\",\n",
" 7.53\n",
" ],\n",
" [\n",
" \"2020-06-20\",\n",
" 7.57\n",
" ],\n",
" [\n",
" \"2020-06-21\",\n",
" 7.68\n",
" ],\n",
" [\n",
" \"2020-06-22\",\n",
" 7.64\n",
" ],\n",
" [\n",
" \"2020-06-23\",\n",
" 7.86\n",
" ],\n",
" [\n",
" \"2020-06-24\",\n",
" 7.67\n",
" ],\n",
" [\n",
" \"2020-06-26\",\n",
" 8.89\n",
" ],\n",
" [\n",
" \"2020-06-27\",\n",
" 8.84\n",
" ],\n",
" [\n",
" \"2020-06-28\",\n",
" 7.86\n",
" ],\n",
" [\n",
" \"2020-06-29\",\n",
" 7.93\n",
" ],\n",
" [\n",
" \"2020-06-30\",\n",
" 7.73\n",
" ],\n",
" [\n",
" \"2020-07-01\",\n",
" 8.11\n",
" ],\n",
" [\n",
" \"2020-07-02\",\n",
" 7.94\n",
" ],\n",
" [\n",
" \"2020-07-03\",\n",
" 8.06\n",
" ],\n",
" [\n",
" \"2020-07-06\",\n",
" 7.61\n",
" ],\n",
" [\n",
" \"2020-07-07\",\n",
" 8.03\n",
" ]\n",
" ],\n",
" \"hoverAnimation\": true,\n",
" \"label\": {\n",
" \"show\": false,\n",
" \"position\": \"top\",\n",
" \"margin\": 8\n",
" },\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\"\n",
" },\n",
" \"areaStyle\": {\n",
" \"opacity\": 0\n",
" },\n",
" \"zlevel\": 0,\n",
" \"z\": 0\n",
" }\n",
" ],\n",
" \"legend\": [\n",
" {\n",
" \"data\": [\n",
" \"\\u5e73\\u5747\\u5fc3\\u7387\",\n",
" \"\\u6700\\u5927\\u5fc3\\u7387\",\n",
" \"\\u5e73\\u5747\\u6b65\\u9891\",\n",
" \"\\u5e73\\u5747\\u901f\\u5ea6\",\n",
" \"\\u5e73\\u5747\\u901f\\u5ea6\"\n",
" ],\n",
" \"selected\": {\n",
" \"\\u5e73\\u5747\\u5fc3\\u7387\": true,\n",
" \"\\u6700\\u5927\\u5fc3\\u7387\": true,\n",
" \"\\u5e73\\u5747\\u6b65\\u9891\": true\n",
" },\n",
" \"show\": true,\n",
" \"padding\": 5,\n",
" \"itemGap\": 10,\n",
" \"itemWidth\": 25,\n",
" \"itemHeight\": 14\n",
" }\n",
" ],\n",
" \"tooltip\": {\n",
" \"show\": true,\n",
" \"trigger\": \"item\",\n",
" \"triggerOn\": \"mousemove|click\",\n",
" \"axisPointer\": {\n",
" \"type\": \"line\"\n",
" },\n",
" \"textStyle\": {\n",
" \"fontSize\": 14\n",
" },\n",
" \"borderWidth\": 0\n",
" },\n",
" \"xAxis\": [\n",
" {\n",
" \"type\": \"category\",\n",
" \"show\": true,\n",
" \"scale\": false,\n",
" \"nameLocation\": \"end\",\n",
" \"nameGap\": 15,\n",
" \"gridIndex\": 0,\n",
" \"axisPointer\": {\n",
" \"show\": true,\n",
" \"type\": \"shadow\"\n",
" },\n",
" \"inverse\": false,\n",
" \"offset\": 0,\n",
" \"splitNumber\": 5,\n",
" \"minInterval\": 0,\n",
" \"splitLine\": {\n",
" \"show\": false,\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\"\n",
" }\n",
" },\n",
" \"data\": [\n",
" \"2020-04-04\",\n",
" \"2020-06-19\",\n",
" \"2020-06-20\",\n",
" \"2020-06-21\",\n",
" \"2020-06-22\",\n",
" \"2020-06-23\",\n",
" \"2020-06-24\",\n",
" \"2020-06-26\",\n",
" \"2020-06-27\",\n",
" \"2020-06-28\",\n",
" \"2020-06-29\",\n",
" \"2020-06-30\",\n",
" \"2020-07-01\",\n",
" \"2020-07-02\",\n",
" \"2020-07-03\",\n",
" \"2020-07-06\",\n",
" \"2020-07-07\"\n",
" ]\n",
" }\n",
" ],\n",
" \"yAxis\": [\n",
" {\n",
" \"type\": \"value\",\n",
" \"name\": \"\\u5fc3\\u7387\",\n",
" \"show\": true,\n",
" \"scale\": false,\n",
" \"nameLocation\": \"end\",\n",
" \"nameGap\": 15,\n",
" \"interval\": 20,\n",
" \"gridIndex\": 0,\n",
" \"axisTick\": {\n",
" \"show\": true,\n",
" \"alignWithLabel\": false,\n",
" \"inside\": false\n",
" },\n",
" \"axisLabel\": {\n",
" \"show\": true,\n",
" \"position\": \"top\",\n",
" \"margin\": 8,\n",
" \"formatter\": \"{value} \\u6b21/\\u5206\\u949f\"\n",
" },\n",
" \"inverse\": false,\n",
" \"offset\": 0,\n",
" \"splitNumber\": 5,\n",
" \"min\": 0,\n",
" \"max\": 180,\n",
" \"minInterval\": 0,\n",
" \"splitLine\": {\n",
" \"show\": true,\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\"\n",
" }\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"value\",\n",
" \"name\": \"\\u5e73\\u5747\\u901f\\u5ea6\",\n",
" \"show\": true,\n",
" \"scale\": false,\n",
" \"nameLocation\": \"end\",\n",
" \"nameGap\": 15,\n",
" \"interval\": 0.272,\n",
" \"gridIndex\": 0,\n",
" \"axisLabel\": {\n",
" \"show\": true,\n",
" \"position\": \"top\",\n",
" \"margin\": 8,\n",
" \"formatter\": \"{value} km/h\"\n",
" },\n",
" \"inverse\": false,\n",
" \"offset\": 0,\n",
" \"splitNumber\": 5,\n",
" \"min\": 7.53,\n",
" \"max\": 8.89,\n",
" \"minInterval\": 0,\n",
" \"splitLine\": {\n",
" \"show\": false,\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\"\n",
" }\n",
" }\n",
" }\n",
" ],\n",
" \"title\": [\n",
" {\n",
" \"text\": \"\\u8fd0\\u52a8\\u5fc3\\u7387\",\n",
" \"subtext\": \"\\u6237\\u5916\\u8fd0\\u52a8\",\n",
" \"padding\": 5,\n",
" \"itemGap\": 10\n",
" }\n",
" ]\n",
"};\n",
" chart_3c959869b1fc4fc6b8f9aedf18b9f8b1.setOption(option_3c959869b1fc4fc6b8f9aedf18b9f8b1);\n",
" </script>\n",
"</body>\n",
"</html>\n"
],
"text/plain": [
"<pyecharts.render.display.HTML at 0x7fd1881bc880>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bar.overlap(line).render_notebook()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"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 0x7fd1881d6e20>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from pyecharts.globals import CurrentConfig, NotebookType\n",
"CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB\n",
"from pyecharts import options as opts\n",
"from pyecharts.charts import Bar,Line\n",
"import pyecharts.options as opts\n",
"\n",
"colors = [\"#5793f3\", \"#d14a61\", \"#675bba\"]\n",
"x_data = []\n",
"y_data1 = []\n",
"y_data2 = []\n",
"y_data3 = []\n",
"for key,value in dict_det.items():\n",
" x_data.append(key)\n",
" y_data1.append(value[6])\n",
" y_data2.append(value[5])\n",
" y_data3.append(value[2])\n",
"bar = (\n",
" Bar()\n",
" .add_xaxis(x_data)\n",
" .add_yaxis(\n",
" series_name=\"平均步幅\", \n",
" yaxis_data=y_data1,\n",
" yaxis_index=0,\n",
" color=colors[1],\n",
" gap=\"0%\"\n",
" )\n",
" .add_yaxis(\"平均步频\", yaxis_data=y_data2, yaxis_index=1, color=colors[0],gap=\"0%\") \n",
" .extend_axis(\n",
" yaxis=opts.AxisOpts(\n",
" name=\"平均步幅\",\n",
" type_=\"value\",\n",
" min_=0,\n",
" max_=200,\n",
" position=\"right\",\n",
" axisline_opts=opts.AxisLineOpts(\n",
" linestyle_opts=opts.LineStyleOpts(color=colors[1])\n",
" ),\n",
" axislabel_opts=opts.LabelOpts(formatter=\"{value} 厘米\"),\n",
" )\n",
" )\n",
" .extend_axis(\n",
" yaxis=opts.AxisOpts(\n",
" name=\"运动时间\",\n",
" type_=\"value\",\n",
" min_=min(y_data3),\n",
" max_=max(y_data3),\n",
" interval=int((max(y_data3)-min(y_data3))/4),\n",
" axislabel_opts=opts.LabelOpts(formatter=\"{value} 分\"),\n",
" position=\"left\",\n",
" )\n",
" )\n",
" .set_global_opts(\n",
" tooltip_opts=opts.TooltipOpts(\n",
" is_show=True, trigger=\"axis\", axis_pointer_type=\"cross\"\n",
" ),\n",
" xaxis_opts=opts.AxisOpts(\n",
" type_=\"category\",\n",
" axispointer_opts=opts.AxisPointerOpts(is_show=True, type_=\"shadow\"),\n",
" ),\n",
" yaxis_opts=opts.AxisOpts(\n",
" name=\"步频\",\n",
" type_=\"value\",\n",
" min_=0,\n",
" max_=200,\n",
" interval=50,\n",
" position=\"right\",\n",
" offset=40,\n",
" axislabel_opts=opts.LabelOpts(formatter=\"{value} 步/分钟\"),\n",
" axistick_opts=opts.AxisTickOpts(is_show=True),\n",
" splitline_opts=opts.SplitLineOpts(is_show=True),\n",
" ),\n",
" )\n",
" .set_global_opts(title_opts=opts.TitleOpts(title=\"运动步幅及步频\", subtitle=\"户外运动\"),)\n",
")\n",
"line = (\n",
" Line()\n",
" .add_xaxis(xaxis_data=x_data)\n",
" .add_yaxis(\n",
" series_name=\"运动时间\",\n",
" yaxis_index=2,\n",
" y_axis=y_data3,\n",
" label_opts=opts.LabelOpts(is_show=False),\n",
" )\n",
")\n",
"\n",
"bar.overlap(line).load_javascript()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<!DOCTYPE html>\n",
"<html>\n",
"<head>\n",
" <meta charset=\"UTF-8\">\n",
"</head>\n",
"<body>\n",
" <div id=\"a2948765b6444401a1a5ae8cff57185d\" class=\"chart-container\" style=\"width:900px; height:500px;\"></div>\n",
" <script>\n",
" var chart_a2948765b6444401a1a5ae8cff57185d = echarts.init(\n",
" document.getElementById('a2948765b6444401a1a5ae8cff57185d'), 'white', {renderer: 'canvas'});\n",
" var option_a2948765b6444401a1a5ae8cff57185d = {\n",
" \"animation\": true,\n",
" \"animationThreshold\": 2000,\n",
" \"animationDuration\": 1000,\n",
" \"animationEasing\": \"cubicOut\",\n",
" \"animationDelay\": 0,\n",
" \"animationDurationUpdate\": 300,\n",
" \"animationEasingUpdate\": \"cubicOut\",\n",
" \"animationDelayUpdate\": 0,\n",
" \"color\": [\n",
" \"#5793f3\",\n",
" \"#d14a61\",\n",
" \"#c23531\",\n",
" \"#2f4554\",\n",
" \"#61a0a8\",\n",
" \"#d48265\",\n",
" \"#749f83\",\n",
" \"#ca8622\",\n",
" \"#bda29a\",\n",
" \"#6e7074\",\n",
" \"#546570\",\n",
" \"#c4ccd3\",\n",
" \"#f05b72\",\n",
" \"#ef5b9c\",\n",
" \"#f47920\",\n",
" \"#905a3d\",\n",
" \"#fab27b\",\n",
" \"#2a5caa\",\n",
" \"#444693\",\n",
" \"#726930\",\n",
" \"#b2d235\",\n",
" \"#6d8346\",\n",
" \"#ac6767\",\n",
" \"#1d953f\",\n",
" \"#6950a1\",\n",
" \"#918597\"\n",
" ],\n",
" \"series\": [\n",
" {\n",
" \"type\": \"bar\",\n",
" \"name\": \"\\u5e73\\u5747\\u6b65\\u5e45\",\n",
" \"yAxisIndex\": 0,\n",
" \"data\": [\n",
" 81.00,\n",
" 77.00,\n",
" 74.00,\n",
" 76.00,\n",
" 75.00,\n",
" 76.00,\n",
" 75.00,\n",
" 85.00,\n",
" 83.00,\n",
" 76.00,\n",
" 76.00,\n",
" 75.00,\n",
" 78.00,\n",
" 76.00,\n",
" 76.00,\n",
" 74.00,\n",
" 78.00\n",
" ],\n",
" \"barCategoryGap\": \"20%\",\n",
" \"barGap\": \"0%\",\n",
" \"label\": {\n",
" \"show\": true,\n",
" \"position\": \"top\",\n",
" \"margin\": 8\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"bar\",\n",
" \"name\": \"\\u5e73\\u5747\\u6b65\\u9891\",\n",
" \"yAxisIndex\": 1,\n",
" \"data\": [\n",
" 167.00,\n",
" 163.00,\n",
" 169.00,\n",
" 169.00,\n",
" 170.00,\n",
" 172.00,\n",
" 171.00,\n",
" 175.00,\n",
" 177.00,\n",
" 173.00,\n",
" 174.00,\n",
" 171.00,\n",
" 174.00,\n",
" 175.00,\n",
" 176.00,\n",
" 171.00,\n",
" 172.00\n",
" ],\n",
" \"barCategoryGap\": \"20%\",\n",
" \"barGap\": \"0%\",\n",
" \"label\": {\n",
" \"show\": true,\n",
" \"position\": \"top\",\n",
" \"margin\": 8\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"line\",\n",
" \"name\": \"\\u8fd0\\u52a8\\u65f6\\u95f4\",\n",
" \"connectNulls\": false,\n",
" \"yAxisIndex\": 2,\n",
" \"symbolSize\": 4,\n",
" \"showSymbol\": true,\n",
" \"smooth\": false,\n",
" \"step\": false,\n",
" \"data\": [\n",
" [\n",
" \"2020-04-04\",\n",
" 37.10\n",
" ],\n",
" [\n",
" \"2020-06-19\",\n",
" 41.36\n",
" ],\n",
" [\n",
" \"2020-06-20\",\n",
" 39.53\n",
" ],\n",
" [\n",
" \"2020-06-21\",\n",
" 39.49\n",
" ],\n",
" [\n",
" \"2020-06-22\",\n",
" 42.34\n",
" ],\n",
" [\n",
" \"2020-06-23\",\n",
" 39.12\n",
" ],\n",
" [\n",
" \"2020-06-24\",\n",
" 42.10\n",
" ],\n",
" [\n",
" \"2020-06-26\",\n",
" 36.18\n",
" ],\n",
" [\n",
" \"2020-06-27\",\n",
" 33.14\n",
" ],\n",
" [\n",
" \"2020-06-28\",\n",
" 38.17\n",
" ],\n",
" [\n",
" \"2020-06-29\",\n",
" 38.53\n",
" ],\n",
" [\n",
" \"2020-06-30\",\n",
" 39.21\n",
" ],\n",
" [\n",
" \"2020-07-01\",\n",
" 37.13\n",
" ],\n",
" [\n",
" \"2020-07-02\",\n",
" 38.10\n",
" ],\n",
" [\n",
" \"2020-07-03\",\n",
" 37.38\n",
" ],\n",
" [\n",
" \"2020-07-06\",\n",
" 40.32\n",
" ],\n",
" [\n",
" \"2020-07-07\",\n",
" 37.49\n",
" ]\n",
" ],\n",
" \"hoverAnimation\": true,\n",
" \"label\": {\n",
" \"show\": false,\n",
" \"position\": \"top\",\n",
" \"margin\": 8\n",
" },\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\"\n",
" },\n",
" \"areaStyle\": {\n",
" \"opacity\": 0\n",
" },\n",
" \"zlevel\": 0,\n",
" \"z\": 0\n",
" },\n",
" {\n",
" \"type\": \"line\",\n",
" \"name\": \"\\u8fd0\\u52a8\\u65f6\\u95f4\",\n",
" \"connectNulls\": false,\n",
" \"yAxisIndex\": 2,\n",
" \"symbolSize\": 4,\n",
" \"showSymbol\": true,\n",
" \"smooth\": false,\n",
" \"step\": false,\n",
" \"data\": [\n",
" [\n",
" \"2020-04-04\",\n",
" 37.10\n",
" ],\n",
" [\n",
" \"2020-06-19\",\n",
" 41.36\n",
" ],\n",
" [\n",
" \"2020-06-20\",\n",
" 39.53\n",
" ],\n",
" [\n",
" \"2020-06-21\",\n",
" 39.49\n",
" ],\n",
" [\n",
" \"2020-06-22\",\n",
" 42.34\n",
" ],\n",
" [\n",
" \"2020-06-23\",\n",
" 39.12\n",
" ],\n",
" [\n",
" \"2020-06-24\",\n",
" 42.10\n",
" ],\n",
" [\n",
" \"2020-06-26\",\n",
" 36.18\n",
" ],\n",
" [\n",
" \"2020-06-27\",\n",
" 33.14\n",
" ],\n",
" [\n",
" \"2020-06-28\",\n",
" 38.17\n",
" ],\n",
" [\n",
" \"2020-06-29\",\n",
" 38.53\n",
" ],\n",
" [\n",
" \"2020-06-30\",\n",
" 39.21\n",
" ],\n",
" [\n",
" \"2020-07-01\",\n",
" 37.13\n",
" ],\n",
" [\n",
" \"2020-07-02\",\n",
" 38.10\n",
" ],\n",
" [\n",
" \"2020-07-03\",\n",
" 37.38\n",
" ],\n",
" [\n",
" \"2020-07-06\",\n",
" 40.32\n",
" ],\n",
" [\n",
" \"2020-07-07\",\n",
" 37.49\n",
" ]\n",
" ],\n",
" \"hoverAnimation\": true,\n",
" \"label\": {\n",
" \"show\": false,\n",
" \"position\": \"top\",\n",
" \"margin\": 8\n",
" },\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\"\n",
" },\n",
" \"areaStyle\": {\n",
" \"opacity\": 0\n",
" },\n",
" \"zlevel\": 0,\n",
" \"z\": 0\n",
" }\n",
" ],\n",
" \"legend\": [\n",
" {\n",
" \"data\": [\n",
" \"\\u5e73\\u5747\\u6b65\\u5e45\",\n",
" \"\\u5e73\\u5747\\u6b65\\u9891\",\n",
" \"\\u8fd0\\u52a8\\u65f6\\u95f4\",\n",
" \"\\u8fd0\\u52a8\\u65f6\\u95f4\"\n",
" ],\n",
" \"selected\": {\n",
" \"\\u5e73\\u5747\\u6b65\\u5e45\": true,\n",
" \"\\u5e73\\u5747\\u6b65\\u9891\": true\n",
" },\n",
" \"show\": true,\n",
" \"padding\": 5,\n",
" \"itemGap\": 10,\n",
" \"itemWidth\": 25,\n",
" \"itemHeight\": 14\n",
" }\n",
" ],\n",
" \"tooltip\": {\n",
" \"show\": true,\n",
" \"trigger\": \"item\",\n",
" \"triggerOn\": \"mousemove|click\",\n",
" \"axisPointer\": {\n",
" \"type\": \"line\"\n",
" },\n",
" \"textStyle\": {\n",
" \"fontSize\": 14\n",
" },\n",
" \"borderWidth\": 0\n",
" },\n",
" \"xAxis\": [\n",
" {\n",
" \"type\": \"category\",\n",
" \"show\": true,\n",
" \"scale\": false,\n",
" \"nameLocation\": \"end\",\n",
" \"nameGap\": 15,\n",
" \"gridIndex\": 0,\n",
" \"axisPointer\": {\n",
" \"show\": true,\n",
" \"type\": \"shadow\"\n",
" },\n",
" \"inverse\": false,\n",
" \"offset\": 0,\n",
" \"splitNumber\": 5,\n",
" \"minInterval\": 0,\n",
" \"splitLine\": {\n",
" \"show\": false,\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\"\n",
" }\n",
" },\n",
" \"data\": [\n",
" \"2020-04-04\",\n",
" \"2020-06-19\",\n",
" \"2020-06-20\",\n",
" \"2020-06-21\",\n",
" \"2020-06-22\",\n",
" \"2020-06-23\",\n",
" \"2020-06-24\",\n",
" \"2020-06-26\",\n",
" \"2020-06-27\",\n",
" \"2020-06-28\",\n",
" \"2020-06-29\",\n",
" \"2020-06-30\",\n",
" \"2020-07-01\",\n",
" \"2020-07-02\",\n",
" \"2020-07-03\",\n",
" \"2020-07-06\",\n",
" \"2020-07-07\"\n",
" ]\n",
" }\n",
" ],\n",
" \"yAxis\": [\n",
" {\n",
" \"type\": \"value\",\n",
" \"name\": \"\\u6b65\\u9891\",\n",
" \"show\": true,\n",
" \"scale\": false,\n",
" \"nameLocation\": \"end\",\n",
" \"nameGap\": 15,\n",
" \"interval\": 50,\n",
" \"gridIndex\": 0,\n",
" \"axisTick\": {\n",
" \"show\": true,\n",
" \"alignWithLabel\": false,\n",
" \"inside\": false\n",
" },\n",
" \"axisLabel\": {\n",
" \"show\": true,\n",
" \"position\": \"top\",\n",
" \"margin\": 8,\n",
" \"formatter\": \"{value} \\u6b65/\\u5206\\u949f\"\n",
" },\n",
" \"inverse\": false,\n",
" \"position\": \"right\",\n",
" \"offset\": 40,\n",
" \"splitNumber\": 5,\n",
" \"min\": 0,\n",
" \"max\": 200,\n",
" \"minInterval\": 0,\n",
" \"splitLine\": {\n",
" \"show\": true,\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\"\n",
" }\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"value\",\n",
" \"name\": \"\\u5e73\\u5747\\u6b65\\u5e45\",\n",
" \"show\": true,\n",
" \"scale\": false,\n",
" \"nameLocation\": \"end\",\n",
" \"nameGap\": 15,\n",
" \"gridIndex\": 0,\n",
" \"axisLine\": {\n",
" \"show\": true,\n",
" \"onZero\": true,\n",
" \"onZeroAxisIndex\": 0,\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\",\n",
" \"color\": \"#d14a61\"\n",
" }\n",
" },\n",
" \"axisLabel\": {\n",
" \"show\": true,\n",
" \"position\": \"top\",\n",
" \"margin\": 8,\n",
" \"formatter\": \"{value} \\u5398\\u7c73\"\n",
" },\n",
" \"inverse\": false,\n",
" \"position\": \"right\",\n",
" \"offset\": 0,\n",
" \"splitNumber\": 5,\n",
" \"min\": 0,\n",
" \"max\": 200,\n",
" \"minInterval\": 0,\n",
" \"splitLine\": {\n",
" \"show\": false,\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\"\n",
" }\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"value\",\n",
" \"name\": \"\\u8fd0\\u52a8\\u65f6\\u95f4\",\n",
" \"show\": true,\n",
" \"scale\": false,\n",
" \"nameLocation\": \"end\",\n",
" \"nameGap\": 15,\n",
" \"interval\": 2,\n",
" \"gridIndex\": 0,\n",
" \"axisLabel\": {\n",
" \"show\": true,\n",
" \"position\": \"top\",\n",
" \"margin\": 8,\n",
" \"formatter\": \"{value} \\u5206\"\n",
" },\n",
" \"inverse\": false,\n",
" \"position\": \"left\",\n",
" \"offset\": 0,\n",
" \"splitNumber\": 5,\n",
" \"min\": 33.14,\n",
" \"max\": 42.34,\n",
" \"minInterval\": 0,\n",
" \"splitLine\": {\n",
" \"show\": false,\n",
" \"lineStyle\": {\n",
" \"show\": true,\n",
" \"width\": 1,\n",
" \"opacity\": 1,\n",
" \"curveness\": 0,\n",
" \"type\": \"solid\"\n",
" }\n",
" }\n",
" }\n",
" ],\n",
" \"title\": [\n",
" {\n",
" \"text\": \"\\u8fd0\\u52a8\\u6b65\\u5e45\\u53ca\\u6b65\\u9891\",\n",
" \"subtext\": \"\\u6237\\u5916\\u8fd0\\u52a8\",\n",
" \"padding\": 5,\n",
" \"itemGap\": 10\n",
" }\n",
" ]\n",
"};\n",
" chart_a2948765b6444401a1a5ae8cff57185d.setOption(option_a2948765b6444401a1a5ae8cff57185d);\n",
" </script>\n",
"</body>\n",
"</html>\n"
],
"text/plain": [
"<pyecharts.render.display.HTML at 0x7fd179b206a0>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bar.overlap(line).render_notebook()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}