image.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. from pywebio.output import put_html
  2. import pyecharts.options as opts
  3. from pyecharts.charts import Line, Bar, Line
  4. def plot_example():
  5. week_name_list = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
  6. high_temperature = [0.83, 0.92, 0.95, 0.87, 0.88, 0.92, 0.9]
  7. low_temperature = [0.43, 0.52, 0.55, 0.47, 0.48, 0.52, 0.5]
  8. c = (
  9. Line()
  10. .add_xaxis(xaxis_data=week_name_list)
  11. .add_yaxis(
  12. series_name="soc一致性",
  13. y_axis=high_temperature,
  14. markpoint_opts=opts.MarkPointOpts(
  15. data=[
  16. opts.MarkPointItem(type_="max", name="最大值"),
  17. opts.MarkPointItem(type_="min", name="最小值"),
  18. ]
  19. ),
  20. markline_opts=opts.MarkLineOpts(
  21. data=[opts.MarkLineItem(type_="average", name="平均值")]
  22. ),
  23. )
  24. .add_yaxis(
  25. series_name="soh一致性",
  26. y_axis=low_temperature,
  27. markpoint_opts=opts.MarkPointOpts(
  28. data=[opts.MarkPointItem(value=-2, name="周最低", x=1, y=-1.5)]
  29. ),
  30. # markline_opts=opts.MarkLineOpts(
  31. # data=[
  32. # opts.MarkLineItem(type_="average", name="平均值"),
  33. # opts.MarkLineItem(symbol="none", x="90%", y="max"),
  34. # opts.MarkLineItem(symbol="circle", type_="max", name="最高点"),
  35. # ]
  36. # ),
  37. )
  38. .set_global_opts(
  39. title_opts=opts.TitleOpts(title="soc/soh致性变化", subtitle="虚构数据"),
  40. tooltip_opts=opts.TooltipOpts(trigger="axis"),
  41. toolbox_opts=opts.ToolboxOpts(is_show=True),
  42. xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=False),
  43. )
  44. )
  45. c.width = "100%"
  46. return c
  47. def plot_example2():
  48. colors = ["#5793f3", "#d14a61", "#675bba"]
  49. x_data = ["0~2h", "2~4h", "4~6h", "6~8h", "8~10h", "10~12h", "12~14h", "14~16h", "16~18h", "18~20h", "20~22h", "22~24h"]
  50. legend_list = ["充电开始时间段"]
  51. evaporation_capacity = [
  52. 1,
  53. 3,
  54. 5,
  55. 3,
  56. 2,
  57. 2,
  58. 0,
  59. 4,
  60. 1,
  61. 5,
  62. 4,
  63. 2,
  64. ]
  65. bar = (
  66. Bar(init_opts=opts.InitOpts(width="800", height="720px"))
  67. .add_xaxis(xaxis_data=x_data)
  68. .add_yaxis(
  69. series_name="充电开始时间段",
  70. y_axis=evaporation_capacity,
  71. yaxis_index=0,
  72. color=colors[1],
  73. )
  74. )
  75. return bar