pyecharts可视化图表
官网介绍
https://pyecharts.org/#/zh-cn/intro
https://gallery.pyecharts.org/#/README
📣 概况
Echarts 是一个由百度开源的数据可视化,凭借着良好的交互性,精巧的图表设计,得到了众多开发者的认可。而 Python 是一门富有表达力的语言,很适合用于数据处理。当数据分析遇上数据可视化时,pyecharts 诞生了。
✨ 特性
- 简洁的 API 设计,使用如丝滑般流畅,支持链式调用
- 囊括了 30+ 种常见图表,应有尽有
- 支持主流 Notebook 环境,Jupyter Notebook 和 JupyterLab
- 可轻松集成至 Flask,Django 等主流 Web 框架
- 高度灵活的配置项,可轻松搭配出精美的图表
- 详细的文档和示例,帮助开发者更快的上手项目
- 多达 400+ 地图文件以及原生的百度地图,为地理数据可视化提供强有力的支持
pip安装
pip install pyecharts
第一个图表
from pyecharts.charts import Bar bar = Bar() bar.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) bar.add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) # render 会生成本地 HTML 文件,默认会在当前目录生成 render.html 文件 # 也可以传入路径参数,如 bar.render("mycharts.html") bar.render()
用链式调用
from pyecharts.charts import Bar bar = ( Bar() .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) .add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) ) bar.render()
使用 options 配置项
from pyecharts.charts import Bar from pyecharts import options as opts # V1 版本开始支持链式调用 # 你所看到的格式其实是 `black` 格式化以后的效果 # 可以执行 `pip install black` 下载使用 bar = ( Bar() .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) .add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) .set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")) # 或者直接使用字典参数 # .set_global_opts(title_opts={"text": "主标题", "subtext": "副标题"}) ) bar.render() # 不习惯链式调用的开发者依旧可以单独调用方法 bar = Bar() bar.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) bar.add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) bar.set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")) bar.render()
渲染成图片文件
from pyecharts.charts import Bar from pyecharts.render import make_snapshot # 使用 snapshot-selenium 渲染图片 from snapshot_selenium import snapshot bar = ( Bar() .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) .add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) ) make_snapshot(snapshot, bar.render(), "bar.png")
记得修改一下chrome_driver的位置
安装snapshot_selenium
pip install snapshot_selenium
from pyecharts.charts import Bar from pyecharts.render import make_snapshot # 使用 snapshot-selenium 渲染图片 from snapshot_selenium import snapshot bar = ( Bar() .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) .add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) ) make_snapshot(snapshot, bar.render(), "bar.png")
使用主题
from pyecharts.charts import Bar from pyecharts import options as opts # 内置主题类型可查看 pyecharts.globals.ThemeType from pyecharts.globals import ThemeType from pyecharts.render import make_snapshot from snapshot_selenium import snapshot bar = ( Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]) .add_yaxis("商家A", [5, 20, 36, 10, 75, 90]) .add_yaxis("商家B", [15, 6, 45, 20, 35, 66]) .set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")) ) make_snapshot(snapshot, bar.render(), "bar.png")
柱状图
Bar - Stack_bar_percent
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.commons.utils import JsCode from pyecharts.globals import ThemeType list2 = [ {"value": 12, "percent": 12 / (12 + 3)}, {"value": 23, "percent": 23 / (23 + 21)}, {"value": 33, "percent": 33 / (33 + 5)}, {"value": 3, "percent": 3 / (3 + 52)}, {"value": 33, "percent": 33 / (33 + 43)}, ] list3 = [ {"value": 3, "percent": 3 / (12 + 3)}, {"value": 21, "percent": 21 / (23 + 21)}, {"value": 5, "percent": 5 / (33 + 5)}, {"value": 52, "percent": 52 / (3 + 52)}, {"value": 43, "percent": 43 / (33 + 43)}, ] c = ( Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) .add_xaxis([1, 2, 3, 4, 5]) .add_yaxis("product1", list2, stack="stack1", category_gap="50%") .add_yaxis("product2", list3, stack="stack1", category_gap="50%") .set_series_opts( label_opts=opts.LabelOpts( position="right", formatter=JsCode( "function(x){return Number(x.data.percent * 100).toFixed() + '%';}" ), ) ) .render("stack_bar_percent.html") )
Bar - Bar_rotate_xaxis_label
from pyecharts import options as opts from pyecharts.charts import Bar c = ( Bar() .add_xaxis( [ "名字很长的X轴标签1", "名字很长的X轴标签2", "名字很长的X轴标签3", "名字很长的X轴标签4", "名字很长的X轴标签5", "名字很长的X轴标签6", ] ) .add_yaxis("商家A", [10, 20, 30, 40, 50, 40]) .add_yaxis("商家B", [20, 10, 40, 30, 40, 50]) .set_global_opts( xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-15)), title_opts=opts.TitleOpts(title="Bar-旋转X轴标签", subtitle="解决标签名字过长的问题"), ) .render("bar_rotate_xaxis_label.html") )
Bar - Bar_stack0
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values(), stack="stack1") .add_yaxis("商家B", Faker.values(), stack="stack1") .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) .set_global_opts(title_opts=opts.TitleOpts(title="Bar-堆叠数据(全部)")) .render("bar_stack0.html") )
Bar - Finance_indices_2002
1 import pyecharts.options as opts 2 from pyecharts.charts import Timeline, Bar, Pie 3 4 """ 5 Gallery 使用 pyecharts 1.1.0 6 参考地址: https://www.echartsjs.com/examples/editor.html?c=mix-timeline-finance 7 8 目前无法实现的功能: 9 10 1、暂无 11 """ 12 total_data = {} 13 name_list = [ 14 "北京", 15 "天津", 16 "河北", 17 "山西", 18 "内蒙古", 19 "辽宁", 20 "吉林", 21 "黑龙江", 22 "上海", 23 "江苏", 24 "浙江", 25 "安徽", 26 "福建", 27 "江西", 28 "山东", 29 "河南", 30 "湖北", 31 "湖南", 32 "广东", 33 "广西", 34 "海南", 35 "重庆", 36 "四川", 37 "贵州", 38 "云南", 39 "西藏", 40 "陕西", 41 "甘肃", 42 "青海", 43 "宁夏", 44 "新疆", 45 ] 46 data_gdp = { 47 2011: [ 48 16251.93, 49 11307.28, 50 24515.76, 51 11237.55, 52 14359.88, 53 22226.7, 54 10568.83, 55 12582, 56 19195.69, 57 49110.27, 58 32318.85, 59 15300.65, 60 17560.18, 61 11702.82, 62 45361.85, 63 26931.03, 64 19632.26, 65 19669.56, 66 53210.28, 67 11720.87, 68 2522.66, 69 10011.37, 70 21026.68, 71 5701.84, 72 8893.12, 73 605.83, 74 12512.3, 75 5020.37, 76 1670.44, 77 2102.21, 78 6610.05, 79 ], 80 2010: [ 81 14113.58, 82 9224.46, 83 20394.26, 84 9200.86, 85 11672, 86 18457.27, 87 8667.58, 88 10368.6, 89 17165.98, 90 41425.48, 91 27722.31, 92 12359.33, 93 14737.12, 94 9451.26, 95 39169.92, 96 23092.36, 97 15967.61, 98 16037.96, 99 46013.06, 100 9569.85, 101 2064.5, 102 7925.58, 103 17185.48, 104 4602.16, 105 7224.18, 106 507.46, 107 10123.48, 108 4120.75, 109 1350.43, 110 1689.65, 111 5437.47, 112 ], 113 2009: [ 114 12153.03, 115 7521.85, 116 17235.48, 117 7358.31, 118 9740.25, 119 15212.49, 120 7278.75, 121 8587, 122 15046.45, 123 34457.3, 124 22990.35, 125 10062.82, 126 12236.53, 127 7655.18, 128 33896.65, 129 19480.46, 130 12961.1, 131 13059.69, 132 39482.56, 133 7759.16, 134 1654.21, 135 6530.01, 136 14151.28, 137 3912.68, 138 6169.75, 139 441.36, 140 8169.8, 141 3387.56, 142 1081.27, 143 1353.31, 144 4277.05, 145 ], 146 2008: [ 147 11115, 148 6719.01, 149 16011.97, 150 7315.4, 151 8496.2, 152 13668.58, 153 6426.1, 154 8314.37, 155 14069.87, 156 30981.98, 157 21462.69, 158 8851.66, 159 10823.01, 160 6971.05, 161 30933.28, 162 18018.53, 163 11328.92, 164 11555, 165 36796.71, 166 7021, 167 1503.06, 168 5793.66, 169 12601.23, 170 3561.56, 171 5692.12, 172 394.85, 173 7314.58, 174 3166.82, 175 1018.62, 176 1203.92, 177 4183.21, 178 ], 179 2007: [ 180 9846.81, 181 5252.76, 182 13607.32, 183 6024.45, 184 6423.18, 185 11164.3, 186 5284.69, 187 7104, 188 12494.01, 189 26018.48, 190 18753.73, 191 7360.92, 192 9248.53, 193 5800.25, 194 25776.91, 195 15012.46, 196 9333.4, 197 9439.6, 198 31777.01, 199 5823.41, 200 1254.17, 201 4676.13, 202 10562.39, 203 2884.11, 204 4772.52, 205 341.43, 206 5757.29, 207 2703.98, 208 797.35, 209 919.11, 210 3523.16, 211 ], 212 2006: [ 213 8117.78, 214 4462.74, 215 11467.6, 216 4878.61, 217 4944.25, 218 9304.52, 219 4275.12, 220 6211.8, 221 10572.24, 222 21742.05, 223 15718.47, 224 6112.5, 225 7583.85, 226 4820.53, 227 21900.19, 228 12362.79, 229 7617.47, 230 7688.67, 231 26587.76, 232 4746.16, 233 1065.67, 234 3907.23, 235 8690.24, 236 2338.98, 237 3988.14, 238 290.76, 239 4743.61, 240 2277.35, 241 648.5, 242 725.9, 243 3045.26, 244 ], 245 2005: [ 246 6969.52, 247 3905.64, 248 10012.11, 249 4230.53, 250 3905.03, 251 8047.26, 252 3620.27, 253 5513.7, 254 9247.66, 255 18598.69, 256 13417.68, 257 5350.17, 258 6554.69, 259 4056.76, 260 18366.87, 261 10587.42, 262 6590.19, 263 6596.1, 264 22557.37, 265 3984.1, 266 918.75, 267 3467.72, 268 7385.1, 269 2005.42, 270 3462.73, 271 248.8, 272 3933.72, 273 1933.98, 274 543.32, 275 612.61, 276 2604.19, 277 ], 278 2004: [ 279 6033.21, 280 3110.97, 281 8477.63, 282 3571.37, 283 3041.07, 284 6672, 285 3122.01, 286 4750.6, 287 8072.83, 288 15003.6, 289 11648.7, 290 4759.3, 291 5763.35, 292 3456.7, 293 15021.84, 294 8553.79, 295 5633.24, 296 5641.94, 297 18864.62, 298 3433.5, 299 819.66, 300 3034.58, 301 6379.63, 302 1677.8, 303 3081.91, 304 220.34, 305 3175.58, 306 1688.49, 307 466.1, 308 537.11, 309 2209.09, 310 ], 311 2003: [ 312 5007.21, 313 2578.03, 314 6921.29, 315 2855.23, 316 2388.38, 317 6002.54, 318 2662.08, 319 4057.4, 320 6694.23, 321 12442.87, 322 9705.02, 323 3923.11, 324 4983.67, 325 2807.41, 326 12078.15, 327 6867.7, 328 4757.45, 329 4659.99, 330 15844.64, 331 2821.11, 332 713.96, 333 2555.72, 334 5333.09, 335 1426.34, 336 2556.02, 337 185.09, 338 2587.72, 339 1399.83, 340 390.2, 341 445.36, 342 1886.35, 343 ], 344 2002: [ 345 4315, 346 2150.76, 347 6018.28, 348 2324.8, 349 1940.94, 350 5458.22, 351 2348.54, 352 3637.2, 353 5741.03, 354 10606.85, 355 8003.67, 356 3519.72, 357 4467.55, 358 2450.48, 359 10275.5, 360 6035.48, 361 4212.82, 362 4151.54, 363 13502.42, 364 2523.73, 365 642.73, 366 2232.86, 367 4725.01, 368 1243.43, 369 2312.82, 370 162.04, 371 2253.39, 372 1232.03, 373 340.65, 374 377.16, 375 1612.6, 376 ], 377 } 378 379 data_pi = { 380 2011: [ 381 136.27, 382 159.72, 383 2905.73, 384 641.42, 385 1306.3, 386 1915.57, 387 1277.44, 388 1701.5, 389 124.94, 390 3064.78, 391 1583.04, 392 2015.31, 393 1612.24, 394 1391.07, 395 3973.85, 396 3512.24, 397 2569.3, 398 2768.03, 399 2665.2, 400 2047.23, 401 659.23, 402 844.52, 403 2983.51, 404 726.22, 405 1411.01, 406 74.47, 407 1220.9, 408 678.75, 409 155.08, 410 184.14, 411 1139.03, 412 ], 413 2010: [ 414 124.36, 415 145.58, 416 2562.81, 417 554.48, 418 1095.28, 419 1631.08, 420 1050.15, 421 1302.9, 422 114.15, 423 2540.1, 424 1360.56, 425 1729.02, 426 1363.67, 427 1206.98, 428 3588.28, 429 3258.09, 430 2147, 431 2325.5, 432 2286.98, 433 1675.06, 434 539.83, 435 685.38, 436 2482.89, 437 625.03, 438 1108.38, 439 68.72, 440 988.45, 441 599.28, 442 134.92, 443 159.29, 444 1078.63, 445 ], 446 2009: [ 447 118.29, 448 128.85, 449 2207.34, 450 477.59, 451 929.6, 452 1414.9, 453 980.57, 454 1154.33, 455 113.82, 456 2261.86, 457 1163.08, 458 1495.45, 459 1182.74, 460 1098.66, 461 3226.64, 462 2769.05, 463 1795.9, 464 1969.69, 465 2010.27, 466 1458.49, 467 462.19, 468 606.8, 469 2240.61, 470 550.27, 471 1067.6, 472 63.88, 473 789.64, 474 497.05, 475 107.4, 476 127.25, 477 759.74, 478 ], 479 2008: [ 480 112.83, 481 122.58, 482 2034.59, 483 313.58, 484 907.95, 485 1302.02, 486 916.72, 487 1088.94, 488 111.8, 489 2100.11, 490 1095.96, 491 1418.09, 492 1158.17, 493 1060.38, 494 3002.65, 495 2658.78, 496 1780, 497 1892.4, 498 1973.05, 499 1453.75, 500 436.04, 501 575.4, 502 2216.15, 503 539.19, 504 1020.56, 505 60.62, 506 753.72, 507 462.27, 508 105.57, 509 118.94, 510 691.07, 511 ], 512 2007: [ 513 101.26, 514 110.19, 515 1804.72, 516 311.97, 517 762.1, 518 1133.42, 519 783.8, 520 915.38, 521 101.84, 522 1816.31, 523 986.02, 524 1200.18, 525 1002.11, 526 905.77, 527 2509.14, 528 2217.66, 529 1378, 530 1626.48, 531 1695.57, 532 1241.35, 533 361.07, 534 482.39, 535 2032, 536 446.38, 537 837.35, 538 54.89, 539 592.63, 540 387.55, 541 83.41, 542 97.89, 543 628.72, 544 ], 545 2006: [ 546 88.8, 547 103.35, 548 1461.81, 549 276.77, 550 634.94, 551 939.43, 552 672.76, 553 750.14, 554 93.81, 555 1545.05, 556 925.1, 557 1011.03, 558 865.98, 559 786.14, 560 2138.9, 561 1916.74, 562 1140.41, 563 1272.2, 564 1532.17, 565 1032.47, 566 323.48, 567 386.38, 568 1595.48, 569 382.06, 570 724.4, 571 50.9, 572 484.81, 573 334, 574 67.55, 575 79.54, 576 527.8, 577 ], 578 2005: [ 579 88.68, 580 112.38, 581 1400, 582 262.42, 583 589.56, 584 882.41, 585 625.61, 586 684.6, 587 90.26, 588 1461.51, 589 892.83, 590 966.5, 591 827.36, 592 727.37, 593 1963.51, 594 1892.01, 595 1082.13, 596 1100.65, 597 1428.27, 598 912.5, 599 300.75, 600 463.4, 601 1481.14, 602 368.94, 603 661.69, 604 48.04, 605 435.77, 606 308.06, 607 65.34, 608 72.07, 609 509.99, 610 ], 611 2004: [ 612 87.36, 613 105.28, 614 1370.43, 615 276.3, 616 522.8, 617 798.43, 618 568.69, 619 605.79, 620 83.45, 621 1367.58, 622 814.1, 623 950.5, 624 786.84, 625 664.5, 626 1778.45, 627 1649.29, 628 1020.09, 629 1022.45, 630 1248.59, 631 817.88, 632 278.76, 633 428.05, 634 1379.93, 635 334.5, 636 607.75, 637 44.3, 638 387.88, 639 286.78, 640 60.7, 641 65.33, 642 461.26, 643 ], 644 2003: [ 645 84.11, 646 89.91, 647 1064.05, 648 215.19, 649 420.1, 650 615.8, 651 488.23, 652 504.8, 653 81.02, 654 1162.45, 655 717.85, 656 749.4, 657 692.94, 658 560, 659 1480.67, 660 1198.7, 661 798.35, 662 886.47, 663 1072.91, 664 658.78, 665 244.29, 666 339.06, 667 1128.61, 668 298.69, 669 494.6, 670 40.7, 671 302.66, 672 237.91, 673 48.47, 674 55.63, 675 412.9, 676 ], 677 2002: [ 678 82.44, 679 84.21, 680 956.84, 681 197.8, 682 374.69, 683 590.2, 684 446.17, 685 474.2, 686 79.68, 687 1110.44, 688 685.2, 689 783.66, 690 664.78, 691 535.98, 692 1390, 693 1288.36, 694 707, 695 847.25, 696 1015.08, 697 601.99, 698 222.89, 699 317.87, 700 1047.95, 701 281.1, 702 463.44, 703 39.75, 704 282.21, 705 215.51, 706 47.31, 707 52.95, 708 305, 709 ], 710 } 711 712 data_si = { 713 2011: [ 714 3752.48, 715 5928.32, 716 13126.86, 717 6635.26, 718 8037.69, 719 12152.15, 720 5611.48, 721 5962.41, 722 7927.89, 723 25203.28, 724 16555.58, 725 8309.38, 726 9069.2, 727 6390.55, 728 24017.11, 729 15427.08, 730 9815.94, 731 9361.99, 732 26447.38, 733 5675.32, 734 714.5, 735 5543.04, 736 11029.13, 737 2194.33, 738 3780.32, 739 208.79, 740 6935.59, 741 2377.83, 742 975.18, 743 1056.15, 744 3225.9, 745 ], 746 2010: [ 747 3388.38, 748 4840.23, 749 10707.68, 750 5234, 751 6367.69, 752 9976.82, 753 4506.31, 754 5025.15, 755 7218.32, 756 21753.93, 757 14297.93, 758 6436.62, 759 7522.83, 760 5122.88, 761 21238.49, 762 13226.38, 763 7767.24, 764 7343.19, 765 23014.53, 766 4511.68, 767 571, 768 4359.12, 769 8672.18, 770 1800.06, 771 3223.49, 772 163.92, 773 5446.1, 774 1984.97, 775 744.63, 776 827.91, 777 2592.15, 778 ], 779 2009: [ 780 2855.55, 781 3987.84, 782 8959.83, 783 3993.8, 784 5114, 785 7906.34, 786 3541.92, 787 4060.72, 788 6001.78, 789 18566.37, 790 11908.49, 791 4905.22, 792 6005.3, 793 3919.45, 794 18901.83, 795 11010.5, 796 6038.08, 797 5687.19, 798 19419.7, 799 3381.54, 800 443.43, 801 3448.77, 802 6711.87, 803 1476.62, 804 2582.53, 805 136.63, 806 4236.42, 807 1527.24, 808 575.33, 809 662.32, 810 1929.59, 811 ], 812 2008: [ 813 2626.41, 814 3709.78, 815 8701.34, 816 4242.36, 817 4376.19, 818 7158.84, 819 3097.12, 820 4319.75, 821 6085.84, 822 16993.34, 823 11567.42, 824 4198.93, 825 5318.44, 826 3554.81, 827 17571.98, 828 10259.99, 829 5082.07, 830 5028.93, 831 18502.2, 832 3037.74, 833 423.55, 834 3057.78, 835 5823.39, 836 1370.03, 837 2452.75, 838 115.56, 839 3861.12, 840 1470.34, 841 557.12, 842 609.98, 843 2070.76, 844 ], 845 2007: [ 846 2509.4, 847 2892.53, 848 7201.88, 849 3454.49, 850 3193.67, 851 5544.14, 852 2475.45, 853 3695.58, 854 5571.06, 855 14471.26, 856 10154.25, 857 3370.96, 858 4476.42, 859 2975.53, 860 14647.53, 861 8282.83, 862 4143.06, 863 3977.72, 864 16004.61, 865 2425.29, 866 364.26, 867 2368.53, 868 4648.79, 869 1124.79, 870 2038.39, 871 98.48, 872 2986.46, 873 1279.32, 874 419.03, 875 455.04, 876 1647.55, 877 ], 878 2006: [ 879 2191.43, 880 2457.08, 881 6110.43, 882 2755.66, 883 2374.96, 884 4566.83, 885 1915.29, 886 3365.31, 887 4969.95, 888 12282.89, 889 8511.51, 890 2711.18, 891 3695.04, 892 2419.74, 893 12574.03, 894 6724.61, 895 3365.08, 896 3187.05, 897 13469.77, 898 1878.56, 899 308.62, 900 1871.65, 901 3775.14, 902 967.54, 903 1705.83, 904 80.1, 905 2452.44, 906 1043.19, 907 331.91, 908 351.58, 909 1459.3, 910 ], 911 2005: [ 912 2026.51, 913 2135.07, 914 5271.57, 915 2357.04, 916 1773.21, 917 3869.4, 918 1580.83, 919 2971.68, 920 4381.2, 921 10524.96, 922 7164.75, 923 2245.9, 924 3175.92, 925 1917.47, 926 10478.62, 927 5514.14, 928 2852.12, 929 2612.57, 930 11356.6, 931 1510.68, 932 240.83, 933 1564, 934 3067.23, 935 821.16, 936 1426.42, 937 63.52, 938 1951.36, 939 838.56, 940 264.61, 941 281.05, 942 1164.79, 943 ], 944 2004: [ 945 1853.58, 946 1685.93, 947 4301.73, 948 1919.4, 949 1248.27, 950 3061.62, 951 1329.68, 952 2487.04, 953 3892.12, 954 8437.99, 955 6250.38, 956 1844.9, 957 2770.49, 958 1566.4, 959 8478.69, 960 4182.1, 961 2320.6, 962 2190.54, 963 9280.73, 964 1253.7, 965 205.6, 966 1376.91, 967 2489.4, 968 681.5, 969 1281.63, 970 52.74, 971 1553.1, 972 713.3, 973 211.7, 974 244.05, 975 914.47, 976 ], 977 2003: [ 978 1487.15, 979 1337.31, 980 3417.56, 981 1463.38, 982 967.49, 983 2898.89, 984 1098.37, 985 2084.7, 986 3209.02, 987 6787.11, 988 5096.38, 989 1535.29, 990 2340.82, 991 1204.33, 992 6485.05, 993 3310.14, 994 1956.02, 995 1777.74, 996 7592.78, 997 984.08, 998 175.82, 999 1135.31, 1000 2014.8, 1001 569.37, 1002 1047.66, 1003 47.64, 1004 1221.17, 1005 572.02, 1006 171.92, 1007 194.27, 1008 719.54, 1009 ], 1010 2002: [ 1011 1249.99, 1012 1069.08, 1013 2911.69, 1014 1134.31, 1015 754.78, 1016 2609.85, 1017 943.49, 1018 1843.6, 1019 2622.45, 1020 5604.49, 1021 4090.48, 1022 1337.04, 1023 2036.97, 1024 941.77, 1025 5184.98, 1026 2768.75, 1027 1709.89, 1028 1523.5, 1029 6143.4, 1030 846.89, 1031 148.88, 1032 958.87, 1033 1733.38, 1034 481.96, 1035 934.88, 1036 32.72, 1037 1007.56, 1038 501.69, 1039 144.51, 1040 153.06, 1041 603.15, 1042 ], 1043 } 1044 1045 data_ti = { 1046 2011: [ 1047 12363.18, 1048 5219.24, 1049 8483.17, 1050 3960.87, 1051 5015.89, 1052 8158.98, 1053 3679.91, 1054 4918.09, 1055 11142.86, 1056 20842.21, 1057 14180.23, 1058 4975.96, 1059 6878.74, 1060 3921.2, 1061 17370.89, 1062 7991.72, 1063 7247.02, 1064 7539.54, 1065 24097.7, 1066 3998.33, 1067 1148.93, 1068 3623.81, 1069 7014.04, 1070 2781.29, 1071 3701.79, 1072 322.57, 1073 4355.81, 1074 1963.79, 1075 540.18, 1076 861.92, 1077 2245.12, 1078 ], 1079 2010: [ 1080 10600.84, 1081 4238.65, 1082 7123.77, 1083 3412.38, 1084 4209.03, 1085 6849.37, 1086 3111.12, 1087 4040.55, 1088 9833.51, 1089 17131.45, 1090 12063.82, 1091 4193.69, 1092 5850.62, 1093 3121.4, 1094 14343.14, 1095 6607.89, 1096 6053.37, 1097 6369.27, 1098 20711.55, 1099 3383.11, 1100 953.67, 1101 2881.08, 1102 6030.41, 1103 2177.07, 1104 2892.31, 1105 274.82, 1106 3688.93, 1107 1536.5, 1108 470.88, 1109 702.45, 1110 1766.69, 1111 ], 1112 2009: [ 1113 9179.19, 1114 3405.16, 1115 6068.31, 1116 2886.92, 1117 3696.65, 1118 5891.25, 1119 2756.26, 1120 3371.95, 1121 8930.85, 1122 13629.07, 1123 9918.78, 1124 3662.15, 1125 5048.49, 1126 2637.07, 1127 11768.18, 1128 5700.91, 1129 5127.12, 1130 5402.81, 1131 18052.59, 1132 2919.13, 1133 748.59, 1134 2474.44, 1135 5198.8, 1136 1885.79, 1137 2519.62, 1138 240.85, 1139 3143.74, 1140 1363.27, 1141 398.54, 1142 563.74, 1143 1587.72, 1144 ], 1145 2008: [ 1146 8375.76, 1147 2886.65, 1148 5276.04, 1149 2759.46, 1150 3212.06, 1151 5207.72, 1152 2412.26, 1153 2905.68, 1154 7872.23, 1155 11888.53, 1156 8799.31, 1157 3234.64, 1158 4346.4, 1159 2355.86, 1160 10358.64, 1161 5099.76, 1162 4466.85, 1163 4633.67, 1164 16321.46, 1165 2529.51, 1166 643.47, 1167 2160.48, 1168 4561.69, 1169 1652.34, 1170 2218.81, 1171 218.67, 1172 2699.74, 1173 1234.21, 1174 355.93, 1175 475, 1176 1421.38, 1177 ], 1178 2007: [ 1179 7236.15, 1180 2250.04, 1181 4600.72, 1182 2257.99, 1183 2467.41, 1184 4486.74, 1185 2025.44, 1186 2493.04, 1187 6821.11, 1188 9730.91, 1189 7613.46, 1190 2789.78, 1191 3770, 1192 1918.95, 1193 8620.24, 1194 4511.97, 1195 3812.34, 1196 3835.4, 1197 14076.83, 1198 2156.76, 1199 528.84, 1200 1825.21, 1201 3881.6, 1202 1312.94, 1203 1896.78, 1204 188.06, 1205 2178.2, 1206 1037.11, 1207 294.91, 1208 366.18, 1209 1246.89, 1210 ], 1211 2006: [ 1212 5837.55, 1213 1902.31, 1214 3895.36, 1215 1846.18, 1216 1934.35, 1217 3798.26, 1218 1687.07, 1219 2096.35, 1220 5508.48, 1221 7914.11, 1222 6281.86, 1223 2390.29, 1224 3022.83, 1225 1614.65, 1226 7187.26, 1227 3721.44, 1228 3111.98, 1229 3229.42, 1230 11585.82, 1231 1835.12, 1232 433.57, 1233 1649.2, 1234 3319.62, 1235 989.38, 1236 1557.91, 1237 159.76, 1238 1806.36, 1239 900.16, 1240 249.04, 1241 294.78, 1242 1058.16, 1243 ], 1244 2005: [ 1245 4854.33, 1246 1658.19, 1247 3340.54, 1248 1611.07, 1249 1542.26, 1250 3295.45, 1251 1413.83, 1252 1857.42, 1253 4776.2, 1254 6612.22, 1255 5360.1, 1256 2137.77, 1257 2551.41, 1258 1411.92, 1259 5924.74, 1260 3181.27, 1261 2655.94, 1262 2882.88, 1263 9772.5, 1264 1560.92, 1265 377.17, 1266 1440.32, 1267 2836.73, 1268 815.32, 1269 1374.62, 1270 137.24, 1271 1546.59, 1272 787.36, 1273 213.37, 1274 259.49, 1275 929.41, 1276 ], 1277 2004: [ 1278 4092.27, 1279 1319.76, 1280 2805.47, 1281 1375.67, 1282 1270, 1283 2811.95, 1284 1223.64, 1285 1657.77, 1286 4097.26, 1287 5198.03, 1288 4584.22, 1289 1963.9, 1290 2206.02, 1291 1225.8, 1292 4764.7, 1293 2722.4, 1294 2292.55, 1295 2428.95, 1296 8335.3, 1297 1361.92, 1298 335.3, 1299 1229.62, 1300 2510.3, 1301 661.8, 1302 1192.53, 1303 123.3, 1304 1234.6, 1305 688.41, 1306 193.7, 1307 227.73, 1308 833.36, 1309 ], 1310 2003: [ 1311 3435.95, 1312 1150.81, 1313 2439.68, 1314 1176.65, 1315 1000.79, 1316 2487.85, 1317 1075.48, 1318 1467.9, 1319 3404.19, 1320 4493.31, 1321 3890.79, 1322 1638.42, 1323 1949.91, 1324 1043.08, 1325 4112.43, 1326 2358.86, 1327 2003.08, 1328 1995.78, 1329 7178.94, 1330 1178.25, 1331 293.85, 1332 1081.35, 1333 2189.68, 1334 558.28, 1335 1013.76, 1336 96.76, 1337 1063.89, 1338 589.91, 1339 169.81, 1340 195.46, 1341 753.91, 1342 ], 1343 2002: [ 1344 2982.57, 1345 997.47, 1346 2149.75, 1347 992.69, 1348 811.47, 1349 2258.17, 1350 958.88, 1351 1319.4, 1352 3038.9, 1353 3891.92, 1354 3227.99, 1355 1399.02, 1356 1765.8, 1357 972.73, 1358 3700.52, 1359 1978.37, 1360 1795.93, 1361 1780.79, 1362 6343.94, 1363 1074.85, 1364 270.96, 1365 956.12, 1366 1943.68, 1367 480.37, 1368 914.5, 1369 89.56, 1370 963.62, 1371 514.83, 1372 148.83, 1373 171.14, 1374 704.5, 1375 ], 1376 } 1377 1378 data_estate = { 1379 2011: [ 1380 12363.18, 1381 5219.24, 1382 8483.17, 1383 3960.87, 1384 5015.89, 1385 8158.98, 1386 3679.91, 1387 4918.09, 1388 11142.86, 1389 20842.21, 1390 14180.23, 1391 4975.96, 1392 6878.74, 1393 3921.2, 1394 17370.89, 1395 7991.72, 1396 7247.02, 1397 7539.54, 1398 24097.7, 1399 3998.33, 1400 1148.93, 1401 3623.81, 1402 7014.04, 1403 2781.29, 1404 3701.79, 1405 322.57, 1406 4355.81, 1407 1963.79, 1408 540.18, 1409 861.92, 1410 2245.12, 1411 ], 1412 2010: [ 1413 10600.84, 1414 4238.65, 1415 7123.77, 1416 3412.38, 1417 4209.03, 1418 6849.37, 1419 3111.12, 1420 4040.55, 1421 9833.51, 1422 17131.45, 1423 12063.82, 1424 4193.69, 1425 5850.62, 1426 3121.4, 1427 14343.14, 1428 6607.89, 1429 6053.37, 1430 6369.27, 1431 20711.55, 1432 3383.11, 1433 953.67, 1434 2881.08, 1435 6030.41, 1436 2177.07, 1437 2892.31, 1438 274.82, 1439 3688.93, 1440 1536.5, 1441 470.88, 1442 702.45, 1443 1766.69, 1444 ], 1445 2009: [ 1446 9179.19, 1447 3405.16, 1448 6068.31, 1449 2886.92, 1450 3696.65, 1451 5891.25, 1452 2756.26, 1453 3371.95, 1454 8930.85, 1455 13629.07, 1456 9918.78, 1457 3662.15, 1458 5048.49, 1459 2637.07, 1460 11768.18, 1461 5700.91, 1462 5127.12, 1463 5402.81, 1464 18052.59, 1465 2919.13, 1466 748.59, 1467 2474.44, 1468 5198.8, 1469 1885.79, 1470 2519.62, 1471 240.85, 1472 3143.74, 1473 1363.27, 1474 398.54, 1475 563.74, 1476 1587.72, 1477 ], 1478 2008: [ 1479 8375.76, 1480 2886.65, 1481 5276.04, 1482 2759.46, 1483 3212.06, 1484 5207.72, 1485 2412.26, 1486 2905.68, 1487 7872.23, 1488 11888.53, 1489 8799.31, 1490 3234.64, 1491 4346.4, 1492 2355.86, 1493 10358.64, 1494 5099.76, 1495 4466.85, 1496 4633.67, 1497 16321.46, 1498 2529.51, 1499 643.47, 1500 2160.48, 1501 4561.69, 1502 1652.34, 1503 2218.81, 1504 218.67, 1505 2699.74, 1506 1234.21, 1507 355.93, 1508 475, 1509 1421.38, 1510 ], 1511 2007: [ 1512 7236.15, 1513 2250.04, 1514 4600.72, 1515 2257.99, 1516 2467.41, 1517 4486.74, 1518 2025.44, 1519 2493.04, 1520 6821.11, 1521 9730.91, 1522 7613.46, 1523 2789.78, 1524 3770, 1525 1918.95, 1526 8620.24, 1527 4511.97, 1528 3812.34, 1529 3835.4, 1530 14076.83, 1531 2156.76, 1532 528.84, 1533 1825.21, 1534 3881.6, 1535 1312.94, 1536 1896.78, 1537 188.06, 1538 2178.2, 1539 1037.11, 1540 294.91, 1541 366.18, 1542 1246.89, 1543 ], 1544 2006: [ 1545 5837.55, 1546 1902.31, 1547 3895.36, 1548 1846.18, 1549 1934.35, 1550 3798.26, 1551 1687.07, 1552 2096.35, 1553 5508.48, 1554 7914.11, 1555 6281.86, 1556 2390.29, 1557 3022.83, 1558 1614.65, 1559 7187.26, 1560 3721.44, 1561 3111.98, 1562 3229.42, 1563 11585.82, 1564 1835.12, 1565 433.57, 1566 1649.2, 1567 3319.62, 1568 989.38, 1569 1557.91, 1570 159.76, 1571 1806.36, 1572 900.16, 1573 249.04, 1574 294.78, 1575 1058.16, 1576 ], 1577 2005: [ 1578 4854.33, 1579 1658.19, 1580 3340.54, 1581 1611.07, 1582 1542.26, 1583 3295.45, 1584 1413.83, 1585 1857.42, 1586 4776.2, 1587 6612.22, 1588 5360.1, 1589 2137.77, 1590 2551.41, 1591 1411.92, 1592 5924.74, 1593 3181.27, 1594 2655.94, 1595 2882.88, 1596 9772.5, 1597 1560.92, 1598 377.17, 1599 1440.32, 1600 2836.73, 1601 815.32, 1602 1374.62, 1603 137.24, 1604 1546.59, 1605 787.36, 1606 213.37, 1607 259.49, 1608 929.41, 1609 ], 1610 2004: [ 1611 4092.27, 1612 1319.76, 1613 2805.47, 1614 1375.67, 1615 1270, 1616 2811.95, 1617 1223.64, 1618 1657.77, 1619 4097.26, 1620 5198.03, 1621 4584.22, 1622 1963.9, 1623 2206.02, 1624 1225.8, 1625 4764.7, 1626 2722.4, 1627 2292.55, 1628 2428.95, 1629 8335.3, 1630 1361.92, 1631 335.3, 1632 1229.62, 1633 2510.3, 1634 661.8, 1635 1192.53, 1636 123.3, 1637 1234.6, 1638 688.41, 1639 193.7, 1640 227.73, 1641 833.36, 1642 ], 1643 2003: [ 1644 3435.95, 1645 1150.81, 1646 2439.68, 1647 1176.65, 1648 1000.79, 1649 2487.85, 1650 1075.48, 1651 1467.9, 1652 3404.19, 1653 4493.31, 1654 3890.79, 1655 1638.42, 1656 1949.91, 1657 1043.08, 1658 4112.43, 1659 2358.86, 1660 2003.08, 1661 1995.78, 1662 7178.94, 1663 1178.25, 1664 293.85, 1665 1081.35, 1666 2189.68, 1667 558.28, 1668 1013.76, 1669 96.76, 1670 1063.89, 1671 589.91, 1672 169.81, 1673 195.46, 1674 753.91, 1675 ], 1676 2002: [ 1677 2982.57, 1678 997.47, 1679 2149.75, 1680 992.69, 1681 811.47, 1682 2258.17, 1683 958.88, 1684 1319.4, 1685 3038.9, 1686 3891.92, 1687 3227.99, 1688 1399.02, 1689 1765.8, 1690 972.73, 1691 3700.52, 1692 1978.37, 1693 1795.93, 1694 1780.79, 1695 6343.94, 1696 1074.85, 1697 270.96, 1698 956.12, 1699 1943.68, 1700 480.37, 1701 914.5, 1702 89.56, 1703 963.62, 1704 514.83, 1705 148.83, 1706 171.14, 1707 704.5, 1708 ], 1709 } 1710 1711 data_financial = { 1712 2011: [ 1713 12363.18, 1714 5219.24, 1715 8483.17, 1716 3960.87, 1717 5015.89, 1718 8158.98, 1719 3679.91, 1720 4918.09, 1721 11142.86, 1722 20842.21, 1723 14180.23, 1724 4975.96, 1725 6878.74, 1726 3921.2, 1727 17370.89, 1728 7991.72, 1729 7247.02, 1730 7539.54, 1731 24097.7, 1732 3998.33, 1733 1148.93, 1734 3623.81, 1735 7014.04, 1736 2781.29, 1737 3701.79, 1738 322.57, 1739 4355.81, 1740 1963.79, 1741 540.18, 1742 861.92, 1743 2245.12, 1744 ], 1745 2010: [ 1746 10600.84, 1747 4238.65, 1748 7123.77, 1749 3412.38, 1750 4209.03, 1751 6849.37, 1752 3111.12, 1753 4040.55, 1754 9833.51, 1755 17131.45, 1756 12063.82, 1757 4193.69, 1758 5850.62, 1759 3121.4, 1760 14343.14, 1761 6607.89, 1762 6053.37, 1763 6369.27, 1764 20711.55, 1765 3383.11, 1766 953.67, 1767 2881.08, 1768 6030.41, 1769 2177.07, 1770 2892.31, 1771 274.82, 1772 3688.93, 1773 1536.5, 1774 470.88, 1775 702.45, 1776 1766.69, 1777 ], 1778 2009: [ 1779 9179.19, 1780 3405.16, 1781 6068.31, 1782 2886.92, 1783 3696.65, 1784 5891.25, 1785 2756.26, 1786 3371.95, 1787 8930.85, 1788 13629.07, 1789 9918.78, 1790 3662.15, 1791 5048.49, 1792 2637.07, 1793 11768.18, 1794 5700.91, 1795 5127.12, 1796 5402.81, 1797 18052.59, 1798 2919.13, 1799 748.59, 1800 2474.44, 1801 5198.8, 1802 1885.79, 1803 2519.62, 1804 240.85, 1805 3143.74, 1806 1363.27, 1807 398.54, 1808 563.74, 1809 1587.72, 1810 ], 1811 2008: [ 1812 8375.76, 1813 2886.65, 1814 5276.04, 1815 2759.46, 1816 3212.06, 1817 5207.72, 1818 2412.26, 1819 2905.68, 1820 7872.23, 1821 11888.53, 1822 8799.31, 1823 3234.64, 1824 4346.4, 1825 2355.86, 1826 10358.64, 1827 5099.76, 1828 4466.85, 1829 4633.67, 1830 16321.46, 1831 2529.51, 1832 643.47, 1833 2160.48, 1834 4561.69, 1835 1652.34, 1836 2218.81, 1837 218.67, 1838 2699.74, 1839 1234.21, 1840 355.93, 1841 475, 1842 1421.38, 1843 ], 1844 2007: [ 1845 7236.15, 1846 2250.04, 1847 4600.72, 1848 2257.99, 1849 2467.41, 1850 4486.74, 1851 2025.44, 1852 2493.04, 1853 6821.11, 1854 9730.91, 1855 7613.46, 1856 2789.78, 1857 3770, 1858 1918.95, 1859 8620.24, 1860 4511.97, 1861 3812.34, 1862 3835.4, 1863 14076.83, 1864 2156.76, 1865 528.84, 1866 1825.21, 1867 3881.6, 1868 1312.94, 1869 1896.78, 1870 188.06, 1871 2178.2, 1872 1037.11, 1873 294.91, 1874 366.18, 1875 1246.89, 1876 ], 1877 2006: [ 1878 5837.55, 1879 1902.31, 1880 3895.36, 1881 1846.18, 1882 1934.35, 1883 3798.26, 1884 1687.07, 1885 2096.35, 1886 5508.48, 1887 7914.11, 1888 6281.86, 1889 2390.29, 1890 3022.83, 1891 1614.65, 1892 7187.26, 1893 3721.44, 1894 3111.98, 1895 3229.42, 1896 11585.82, 1897 1835.12, 1898 433.57, 1899 1649.2, 1900 3319.62, 1901 989.38, 1902 1557.91, 1903 159.76, 1904 1806.36, 1905 900.16, 1906 249.04, 1907 294.78, 1908 1058.16, 1909 ], 1910 2005: [ 1911 4854.33, 1912 1658.19, 1913 3340.54, 1914 1611.07, 1915 1542.26, 1916 3295.45, 1917 1413.83, 1918 1857.42, 1919 4776.2, 1920 6612.22, 1921 5360.1, 1922 2137.77, 1923 2551.41, 1924 1411.92, 1925 5924.74, 1926 3181.27, 1927 2655.94, 1928 2882.88, 1929 9772.5, 1930 1560.92, 1931 377.17, 1932 1440.32, 1933 2836.73, 1934 815.32, 1935 1374.62, 1936 137.24, 1937 1546.59, 1938 787.36, 1939 213.37, 1940 259.49, 1941 929.41, 1942 ], 1943 2004: [ 1944 4092.27, 1945 1319.76, 1946 2805.47, 1947 1375.67, 1948 1270, 1949 2811.95, 1950 1223.64, 1951 1657.77, 1952 4097.26, 1953 5198.03, 1954 4584.22, 1955 1963.9, 1956 2206.02, 1957 1225.8, 1958 4764.7, 1959 2722.4, 1960 2292.55, 1961 2428.95, 1962 8335.3, 1963 1361.92, 1964 335.3, 1965 1229.62, 1966 2510.3, 1967 661.8, 1968 1192.53, 1969 123.3, 1970 1234.6, 1971 688.41, 1972 193.7, 1973 227.73, 1974 833.36, 1975 ], 1976 2003: [ 1977 3435.95, 1978 1150.81, 1979 2439.68, 1980 1176.65, 1981 1000.79, 1982 2487.85, 1983 1075.48, 1984 1467.9, 1985 3404.19, 1986 4493.31, 1987 3890.79, 1988 1638.42, 1989 1949.91, 1990 1043.08, 1991 4112.43, 1992 2358.86, 1993 2003.08, 1994 1995.78, 1995 7178.94, 1996 1178.25, 1997 293.85, 1998 1081.35, 1999 2189.68, 2000 558.28, 2001 1013.76, 2002 96.76, 2003 1063.89, 2004 589.91, 2005 169.81, 2006 195.46, 2007 753.91, 2008 ], 2009 2002: [ 2010 2982.57, 2011 997.47, 2012 2149.75, 2013 992.69, 2014 811.47, 2015 2258.17, 2016 958.88, 2017 1319.4, 2018 3038.9, 2019 3891.92, 2020 3227.99, 2021 1399.02, 2022 1765.8, 2023 972.73, 2024 3700.52, 2025 1978.37, 2026 1795.93, 2027 1780.79, 2028 6343.94, 2029 1074.85, 2030 270.96, 2031 956.12, 2032 1943.68, 2033 480.37, 2034 914.5, 2035 89.56, 2036 963.62, 2037 514.83, 2038 148.83, 2039 171.14, 2040 704.5, 2041 ], 2042 } 2043 2044 2045 def format_data(data: dict) -> dict: 2046 for year in range(2002, 2012): 2047 max_data, sum_data = 0, 0 2048 temp = data[year] 2049 max_data = max(temp) 2050 for i in range(len(temp)): 2051 sum_data += temp[i] 2052 data[year][i] = {"name": name_list[i], "value": temp[i]} 2053 data[str(year) + "max"] = int(max_data / 100) * 100 2054 data[str(year) + "sum"] = sum_data 2055 return data 2056 2057 2058 # GDP 2059 total_data["dataGDP"] = format_data(data=data_gdp) 2060 # 第一产业 2061 total_data["dataPI"] = format_data(data=data_pi) 2062 # 第二产业 2063 total_data["dataSI"] = format_data(data=data_si) 2064 # 第三产业 2065 total_data["dataTI"] = format_data(data=data_ti) 2066 # 房地产 2067 total_data["dataEstate"] = format_data(data=data_estate) 2068 # 金融 2069 total_data["dataFinancial"] = format_data(data=data_financial) 2070 2071 2072 ##################################################################################### 2073 # 2002 - 2011 年的数据 2074 def get_year_overlap_chart(year: int) -> Bar: 2075 bar = ( 2076 Bar() 2077 .add_xaxis(xaxis_data=name_list) 2078 .add_yaxis( 2079 series_name="GDP", 2080 y_axis=total_data["dataGDP"][year], # y_axis= y_data yaxis_data=total_data["dataGDP"][year] 2081 is_selected=False, 2082 label_opts=opts.LabelOpts(is_show=False), 2083 ) 2084 .add_yaxis( 2085 series_name="金融", 2086 y_axis=total_data["dataFinancial"][year], # y_axis= y_data yaxis_data=total_data["dataFinancial"][year] 2087 is_selected=False, 2088 label_opts=opts.LabelOpts(is_show=False), 2089 ) 2090 .add_yaxis( 2091 series_name="房地产", 2092 y_axis=total_data["dataEstate"][year], 2093 is_selected=False, 2094 label_opts=opts.LabelOpts(is_show=False), 2095 ) 2096 .add_yaxis( 2097 series_name="第一产业", 2098 y_axis=total_data["dataPI"][year], 2099 label_opts=opts.LabelOpts(is_show=False), 2100 ) 2101 .add_yaxis( 2102 series_name="第二产业", 2103 y_axis=total_data["dataSI"][year], 2104 label_opts=opts.LabelOpts(is_show=False), 2105 ) 2106 .add_yaxis( 2107 series_name="第三产业", 2108 y_axis=total_data["dataTI"][year], 2109 label_opts=opts.LabelOpts(is_show=False), 2110 ) 2111 .set_global_opts( 2112 title_opts=opts.TitleOpts( 2113 title="{}全国宏观经济指标".format(year), subtitle="数据来自国家统计局" 2114 ), 2115 tooltip_opts=opts.TooltipOpts( 2116 is_show=True, trigger="axis", axis_pointer_type="shadow" 2117 ), 2118 ) 2119 ) 2120 pie = ( 2121 Pie() 2122 .add( 2123 series_name="GDP占比", 2124 data_pair=[ 2125 ["第一产业", total_data["dataPI"]["{}sum".format(year)]], 2126 ["第二产业", total_data["dataSI"]["{}sum".format(year)]], 2127 ["第三产业", total_data["dataTI"]["{}sum".format(year)]], 2128 ], 2129 center=["75%", "35%"], 2130 radius="28%", 2131 ) 2132 .set_series_opts(tooltip_opts=opts.TooltipOpts(is_show=True, trigger="item")) 2133 ) 2134 return bar.overlap(pie) 2135 2136 2137 # 生成时间轴的图 2138 timeline = Timeline(init_opts=opts.InitOpts(width="1600px", height="800px")) 2139 2140 for y in range(2002, 2012): 2141 timeline.add(get_year_overlap_chart(year=y), time_point=str(y)) 2142 2143 # 1.0.0 版本的 add_schema 暂时没有补上 return self 所以只能这么写着 2144 timeline.add_schema(is_auto_play=True, play_interval=1000) 2145 timeline.render("finance_indices_2002.html")
Bar - Bar_base_dict_config
from pyecharts.charts import Bar from pyecharts.faker import Faker from pyecharts.globals import ThemeType c = ( Bar({"theme": ThemeType.MACARONS}) .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values()) .add_yaxis("商家B", Faker.values()) .set_global_opts( title_opts={"text": "Bar-通过 dict 进行配置", "subtext": "我也是通过 dict 进行配置的"} ) .render("bar_base_dict_config.html") )
Bar - Bar_with_brush
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values()) .add_yaxis("商家B", Faker.values()) .set_global_opts( title_opts=opts.TitleOpts(title="Bar-Brush示例", subtitle="我是副标题"), brush_opts=opts.BrushOpts(), ) .render("bar_with_brush.html") )
Bar - Bar_datazoom_slider
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.days_attrs) .add_yaxis("商家A", Faker.days_values) .set_global_opts( title_opts=opts.TitleOpts(title="Bar-DataZoom(slider-水平)"), datazoom_opts=opts.DataZoomOpts(), ) .render("bar_datazoom_slider.html") )
Bar - Bar_toolbox
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values()) .add_yaxis("商家B", Faker.values()) .set_global_opts( title_opts=opts.TitleOpts(title="Bar-显示 ToolBox"), toolbox_opts=opts.ToolboxOpts(), legend_opts=opts.LegendOpts(is_show=False), ) .render("bar_toolbox.html") )
Bar - Bar_waterfall_plot
from pyecharts.charts import Bar from pyecharts import options as opts x_data = [f"11月{str(i)}日" for i in range(1, 12)] y_total = [0, 900, 1245, 1530, 1376, 1376, 1511, 1689, 1856, 1495, 1292] y_in = [900, 345, 393, "-", "-", 135, 178, 286, "-", "-", "-"] y_out = ["-", "-", "-", 108, 154, "-", "-", "-", 119, 361, 203] bar = ( Bar() .add_xaxis(xaxis_data=x_data) .add_yaxis( series_name="", y_axis=y_total, # y_axis yaxis_data stack="总量", itemstyle_opts=opts.ItemStyleOpts(color="rgba(0,0,0,0)"), ) .add_yaxis(series_name="收入", y_axis=y_in, stack="总量") .add_yaxis(series_name="支出", y_axis=y_out, stack="总量") .set_global_opts(yaxis_opts=opts.AxisOpts(type_="value")) .render("bar_waterfall_plot.html") )
Bar - Mixed_bar_and_line
import pyecharts.options as opts from pyecharts.charts import Bar, Line """ Gallery 使用 pyecharts 1.1.0 参考地址: https://www.echartsjs.com/examples/editor.html?c=mix-line-bar 目前无法实现的功能: 1、暂无 """ x_data = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"] bar = ( Bar(init_opts=opts.InitOpts(width="1600px", height="800px")) .add_xaxis(xaxis_data=x_data) .add_yaxis( series_name="蒸发量", y_axis=[ # y_axis yaxis_data 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3, ], label_opts=opts.LabelOpts(is_show=False), ) .add_yaxis( series_name="降水量", y_axis=[ 2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3, ], label_opts=opts.LabelOpts(is_show=False), ) .extend_axis( yaxis=opts.AxisOpts( name="温度", type_="value", min_=0, max_=25, interval=5, axislabel_opts=opts.LabelOpts(formatter="{value} °C"), ) ) .set_global_opts( tooltip_opts=opts.TooltipOpts( is_show=True, trigger="axis", axis_pointer_type="cross" ), xaxis_opts=opts.AxisOpts( type_="category", axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"), ), yaxis_opts=opts.AxisOpts( name="水量", type_="value", min_=0, max_=250, interval=50, axislabel_opts=opts.LabelOpts(formatter="{value} ml"), axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), ) ) line = ( Line() .add_xaxis(xaxis_data=x_data) .add_yaxis( series_name="平均温度", yaxis_index=1, y_axis=[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2], label_opts=opts.LabelOpts(is_show=False), ) ) bar.overlap(line).render("mixed_bar_and_line.html")
Bar - Bar_grahic_component
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.commons.utils import JsCode from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values()) .add_yaxis("商家B", Faker.values()) .set_global_opts( title_opts=opts.TitleOpts(title="Bar-Graphic 组件示例"), graphic_opts=[ opts.GraphicGroup( graphic_item=opts.GraphicItem( rotation=JsCode("Math.PI / 4"), bounding="raw", right=110, bottom=110, z=100, ), children=[ # opts.GraphicRect( # graphic_item=opts.GraphicItem( # left="center", top="center", z=100 # ), # graphic_shape_opts=opts.GraphicShapeOpts(width=400, height=50), # graphic_basicstyle_opts=opts.GraphicBasicStyleOpts( # fill="rgba(0,0,0,0.3)" # ), # ), # opts.GraphicText( # graphic_item=opts.GraphicItem( # left="center", top="center", z=100 # ), # graphic_textstyle_opts=opts.GraphicTextStyleOpts( # text="pyecharts bar chart", # font="bold 26px Microsoft YaHei", # graphic_basicstyle_opts=opts.GraphicBasicStyleOpts( # fill="#fff" # ), # ), # ), ], ) ], ) .render("bar_graphic_component.html") )
Bar - Bar_stack1
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values(), stack="stack1") .add_yaxis("商家B", Faker.values(), stack="stack1") .add_yaxis("商家C", Faker.values()) .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) .set_global_opts(title_opts=opts.TitleOpts(title="Bar-堆叠数据(部分)")) .render("bar_stack1.html") )
Bar - Bar_xyaxis_name
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values()) .add_yaxis("商家B", Faker.values()) .set_global_opts( title_opts=opts.TitleOpts(title="Bar-XY 轴名称"), yaxis_opts=opts.AxisOpts(name="我是 Y 轴"), xaxis_opts=opts.AxisOpts(name="我是 X 轴"), ) .render("bar_xyaxis_name.html") )
Bar - Bar_base_with_custom_background_image
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.commons.utils import JsCode from pyecharts.faker import Faker c = ( Bar( init_opts=opts.InitOpts( bg_color={"type": "pattern", "image": JsCode("img"), "repeat": "no-repeat"} ) ) .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values()) .add_yaxis("商家B", Faker.values()) .set_global_opts( title_opts=opts.TitleOpts( title="Bar-背景图基本示例", subtitle="我是副标题", title_textstyle_opts=opts.TextStyleOpts(color="white"), ) ) ) c.add_js_funcs( """ var img = new Image(); img.src = 'https://s2.ax1x.com/2019/07/08/ZsS0fK.jpg'; """ ) c.render("bar_base_with_custom_background_image.html")
Bar - Bar_chart_display_delay
import pyecharts.options as opts from pyecharts.charts import Bar """ Gallery 使用 pyecharts 1.1.0 参考地址: https://www.echartsjs.com/examples/editor.html?c=bar-animation-delay 目前无法实现的功能: 1、动画延迟效果暂时没有加入到代码中 """ category = ["类目{}".format(i) for i in range(0, 100)] red_bar = [ 0, -8.901463875624668, -17.025413764148556, -24.038196249566663, -29.66504684804471, -33.699527649688676, -36.00971978255796, -36.541005056170455, -35.31542466107655, -32.427752866005996, -28.038563739693934, -22.364693082297347, -15.667600860943732, -8.240217424060843, -0.3929067389459173, 7.560799717904647, 15.318054209871054, 22.599523033552096, 29.16065418543528, 34.800927952557615, 39.37074152590451, 42.77569739999406, 44.97819140223978, 45.99632376477021, 45.900279829731865, 44.806440199911805, 42.86957840395034, 40.2735832137877, 37.22119936652441, 33.92331243435557, 30.588309963978517, 27.412031986865767, 24.56878097935778, 22.203796820272576, 20.427519715115604, 19.311867685884827, 18.888649906111855, 19.150128087782186, 20.051630602288828, 21.516023200879346, 23.439750867099516, 25.700091656548704, 28.163208735293757, 30.692553648214542, 33.1571635093161, 35.439407573791215, 37.44177367693234, 39.09234039030659, 40.34865356244595, 41.19981246258526, 41.66666666666667, 41.80012531240646, 41.67768039516203, 41.39834040182826, 41.07625507973403, 40.833382300579814, 40.79160029175877, 41.06470032034727, 41.75070457358366, 42.924940903672564, 44.63427081999565, 46.89281122872821, 49.679416561286956, 52.93709961387478, 56.574470884754874, 60.46917221906629, 64.47317623531558, 68.41972346252496, 72.1315793340836, 75.43021771943799, 78.14548044723074, 80.12522637371026, 81.24447108408411, 81.41353029256493, 80.58471628367427, 78.75719600392792, 75.97969924353211, 72.35086229880064, 68.01710226438443, 63.16803467673056, 58.029567166714706, 52.854918421647554, 47.91391949819902, 43.48104807503482, 39.82272085822884, 37.18442111754884, 35.778264289169215, 35.77160292258658, 37.27724241244461, 40.345781666728996, 44.96051012913295, 51.035187614675685, 58.41491053964701, 66.8801325453253, 76.15376513468516, 85.91114110149952, 95.79248672571518, 105.41742429574506, 114.40092042993717, 122.37001313784816, ] blue_bar = [ -50, -47.18992898088751, -42.54426104547181, -36.290773900754886, -28.71517529663627, -20.146937097399626, -10.94374119697364, -1.4752538113770308, 7.893046603320797, 16.81528588241657, 24.979206795219028, 32.11821023962515, 38.02096119056733, 42.53821720798438, 45.58667093073836, 47.14973738101559, 47.275355710354944, 46.07100702178889, 43.6962693226927, 40.35333240268025, 36.275975292575026, 31.71756381888028, 26.938653692729076, 22.194784893913152, 17.725026430574392, 13.741778696752679, 10.422266555457615, 7.902063853319403, 6.270884006107842, 5.570756810898967, 5.796594266992678, 6.899033489892203, 8.7893381290192, 11.346045936704996, 14.42297348773613, 17.858132851517098, 21.483081596548438, 25.132218074866262, 28.651548555679597, 31.906490373810854, 34.788333671419466, 37.21906041552118, 39.154309232933485, 40.58437366457342, 41.5332247510366, 42.05565130942339, 42.23270781895, 42.165745792772285, 41.969375711588256, 41.76375960543808, 41.66666666666667, 41.7857343479728, 42.21136481847887, 43.01065209435119, 44.22268037417866, 45.855461823273586, 47.88469584957917, 50.25443606443524, 52.879650371477126, 55.650558977584225, 58.43853958732492, 61.10330341815434, 63.500974294013034, 65.49264961151306, 66.95298925309743, 67.77836838841961, 67.89414332224722, 67.26061575374229, 65.87733853082335, 63.785482681031894, 61.068077697490004, 57.84804048526095, 54.284018163297375, 50.564180830851214, 46.89820707575337, 43.50780217852947, 40.616171775045245, 38.4369379107128, 37.16302649485318, 36.95607267600796, 37.93688225696513, 40.17745279877072, 43.694998595987045, 48.44834150353593, 54.33692802801367, 61.20261650152743, 68.83425165632042, 76.97491319735354, 85.33159602026458, 93.58695857541488, 101.4126683297632, 108.48378461530217, 114.49355390682695, 119.16795429637915, 122.27931702317058, 123.65837448506679, 123.20413594805603, 120.89107255501017, 116.7731992576505, 110.98476877890735, ] ( Bar(init_opts=opts.InitOpts(width="1600px", height="800px")) .add_xaxis(xaxis_data=category) .add_yaxis( series_name="bar", y_axis=red_bar, label_opts=opts.LabelOpts(is_show=False) # y_axis yaxis_data ) .add_yaxis( series_name="bar2", y_axis=blue_bar, label_opts=opts.LabelOpts(is_show=False), ) .set_global_opts( title_opts=opts.TitleOpts(title="柱状图动画延迟"), xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=False)), yaxis_opts=opts.AxisOpts( axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), ) .render("bar_chart_display_delay.html") )
Bar - Bar_datazoom_slider_vertical
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.days_attrs) .add_yaxis("商家A", Faker.days_values, color=Faker.rand_color()) .set_global_opts( title_opts=opts.TitleOpts(title="Bar-DataZoom(slider-垂直)"), datazoom_opts=opts.DataZoomOpts(orient="vertical"), ) .render("bar_datazoom_slider_vertical.html") )
Bar - Bar_histogram_color
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker x = Faker.dogs + Faker.animal xlen = len(x) y = [] for idx, item in enumerate(x): if idx <= xlen / 2: y.append( opts.BarItem( name=item, value=(idx + 1) * 10, itemstyle_opts=opts.ItemStyleOpts(color="#749f83"), ) ) else: y.append( opts.BarItem( name=item, value=(xlen + 1 - idx) * 10, itemstyle_opts=opts.ItemStyleOpts(color="#d48265"), ) ) c = ( Bar() .add_xaxis(x) .add_yaxis("series0", y, category_gap=0, color=Faker.rand_color()) .set_global_opts(title_opts=opts.TitleOpts(title="Bar-直方图(颜色区分)")) .render("bar_histogram_color.html") )
Bar - Bar_yaxis_formatter
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values()) .add_yaxis("商家B", Faker.values()) .set_global_opts( title_opts=opts.TitleOpts(title="Bar-Y 轴 formatter"), yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} /月")), ) .render("bar_yaxis_formatter.html") )
Bar - Bar_markpoint_type
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values()) .add_yaxis("商家B", Faker.values()) .set_global_opts(title_opts=opts.TitleOpts(title="Bar-MarkPoint(指定类型)")) .set_series_opts( label_opts=opts.LabelOpts(is_show=False), markpoint_opts=opts.MarkPointOpts( data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), opts.MarkPointItem(type_="average", name="平均值"), ] ), ) .render("bar_markpoint_type.html") )
Bar - Multiple_y_axes
import pyecharts.options as opts from pyecharts.charts import Bar, Line """ Gallery 使用 pyecharts 1.0.0 参考地址: https://www.echartsjs.com/examples/editor.html?c=multiple-y-axis 目前无法实现的功能: 1、暂无 """ colors = ["#5793f3", "#d14a61", "#675bba"] x_data = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"] legend_list = ["蒸发量", "降水量", "平均温度"] evaporation_capacity = [ 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3, ] rainfall_capacity = [ 2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3, ] average_temperature = [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2] bar = ( Bar(init_opts=opts.InitOpts(width="1680px", height="800px")) .add_xaxis(xaxis_data=x_data) .add_yaxis( series_name="蒸发量", y_axis=evaporation_capacity, # y_axis yaxis_data yaxis_index=0, color=colors[1], ) .add_yaxis( series_name="降水量", y_axis=rainfall_capacity, yaxis_index=1, color=colors[0] ) .extend_axis( yaxis=opts.AxisOpts( name="蒸发量", type_="value", min_=0, max_=250, position="right", axisline_opts=opts.AxisLineOpts( linestyle_opts=opts.LineStyleOpts(color=colors[1]) ), axislabel_opts=opts.LabelOpts(formatter="{value} ml"), ) ) .extend_axis( yaxis=opts.AxisOpts( type_="value", name="温度", min_=0, max_=25, position="left", axisline_opts=opts.AxisLineOpts( linestyle_opts=opts.LineStyleOpts(color=colors[2]) ), axislabel_opts=opts.LabelOpts(formatter="{value} °C"), splitline_opts=opts.SplitLineOpts( is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1) ), ) ) .set_global_opts( yaxis_opts=opts.AxisOpts( type_="value", name="降水量", min_=0, max_=250, position="right", offset=80, axisline_opts=opts.AxisLineOpts( linestyle_opts=opts.LineStyleOpts(color=colors[0]) ), axislabel_opts=opts.LabelOpts(formatter="{value} ml"), ), tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"), ) ) line = ( Line() .add_xaxis(xaxis_data=x_data) .add_yaxis( series_name="平均温度", y_axis=average_temperature, yaxis_index=2, color=colors[2] ) ) bar.overlap(line).render("multiple_y_axes.html")
Bar - Bar_custom_bar_color
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.commons.utils import JsCode from pyecharts.faker import Faker color_function = """ function (params) { if (params.value > 0 && params.value < 50) { return 'red'; } else if (params.value > 50 && params.value < 100) { return 'blue'; } return 'green'; } """ c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis( "商家A", Faker.values(), itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)), ) .add_yaxis( "商家B", Faker.values(), itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)), ) .add_yaxis( "商家C", Faker.values(), itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)), ) .set_global_opts(title_opts=opts.TitleOpts(title="Bar-自定义柱状颜色")) .render("bar_custom_bar_color.html") )
Bar - Bar_different_series_gap
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values(), gap="0%") .add_yaxis("商家B", Faker.values(), gap="0%") .set_global_opts(title_opts=opts.TitleOpts(title="Bar-不同系列柱间距离")) .render("bar_different_series_gap.html") )
Bar - Bar_markline_type
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values()) .add_yaxis("商家B", Faker.values()) .set_global_opts(title_opts=opts.TitleOpts(title="Bar-MarkLine(指定类型)")) .set_series_opts( label_opts=opts.LabelOpts(is_show=False), markline_opts=opts.MarkLineOpts( data=[ opts.MarkLineItem(type_="min", name="最小值"), opts.MarkLineItem(type_="max", name="最大值"), opts.MarkLineItem(type_="average", name="平均值"), ] ), ) .render("bar_markline_type.html") )
Bar - Bar_border_radius
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.commons.utils import JsCode from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values(), category_gap="60%") .set_series_opts( itemstyle_opts={ "normal": { "color": JsCode( """new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(0, 244, 255, 1)' }, { offset: 1, color: 'rgba(0, 77, 167, 1)' }], false)""" ), "barBorderRadius": [30, 30, 30, 30], "shadowColor": "rgb(0, 160, 221)", } } ) .set_global_opts(title_opts=opts.TitleOpts(title="Bar-渐变圆柱")) .render("bar_border_radius.html") )
Bar - Bar_same_series_gap
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.choose()) .add_yaxis("商家A", Faker.values(), category_gap="80%") .set_global_opts(title_opts=opts.TitleOpts(title="Bar-单系列柱间距离")) .render("bar_same_series_gap.html") )
Bar - Bar_datazoom_inside
from pyecharts import options as opts from pyecharts.charts import Bar from pyecharts.faker import Faker c = ( Bar() .add_xaxis(Faker.days_attrs) .add_yaxis("商家A", Faker.days_values, color=Faker.rand_color()) .set_global_opts( title_opts=opts.TitleOpts(title="Bar-DataZoom(inside)"), datazoom_opts=opts.DataZoomOpts(type_="inside"), ) .render("bar_datazoom_inside.html") )