|
@@ -1,11 +1,13 @@
|
|
|
-import pandas as pd
|
|
|
import json
|
|
|
import pymysql
|
|
|
+import pyecharts.options as opts
|
|
|
+from pyecharts.charts import Line
|
|
|
|
|
|
|
|
|
class Analysis(object):
|
|
|
def __init__(self):
|
|
|
- self.platform_list = ["xiaoniangao", "gongzhonghao", "shipinhao", "douyin", "kuaishou", "fuqiwang", "haitunzhufu"]
|
|
|
+ self.platform_list = ["xiaoniangao", "gongzhonghao", "shipinhao", "douyin", "kuaishou", "fuqiwang",
|
|
|
+ "haitunzhufu"]
|
|
|
self.date_last = "2023-11-01"
|
|
|
self.out_put = {}
|
|
|
|
|
@@ -36,7 +38,43 @@ class Analysis(object):
|
|
|
connection.close()
|
|
|
|
|
|
|
|
|
+class Drawer(object):
|
|
|
+ def __init__(self, json_obj):
|
|
|
+ self.ori_data = json_obj
|
|
|
+ self.x_list = ["2023-11-{:02}".format(i) for i in range(1, 22)]
|
|
|
+
|
|
|
+ def draw_line(self):
|
|
|
+ line = Line()
|
|
|
+ line.add_xaxis(xaxis_data=self.x_list)
|
|
|
+ for key in self.ori_data:
|
|
|
+ # print(key, self.ori_data[key])
|
|
|
+ each_obj = self.ori_data[key]
|
|
|
+ line.add_yaxis(
|
|
|
+ series_name=key,
|
|
|
+ stack="Total",
|
|
|
+ y_axis=[each_obj.get(i, 0) for i in self.x_list],
|
|
|
+ label_opts=opts.LabelOpts(is_show=False),
|
|
|
+ is_smooth=True
|
|
|
+ )
|
|
|
+ line.set_global_opts(
|
|
|
+ title_opts=opts.TitleOpts(title="入库量折线图", item_gap=10, padding=10, pos_top="10"),
|
|
|
+ legend_opts=opts.LegendOpts(pos_right=True),
|
|
|
+ tooltip_opts=opts.TooltipOpts(trigger="axis", padding=100),
|
|
|
+ yaxis_opts=opts.AxisOpts(
|
|
|
+ type_="value",
|
|
|
+ axistick_opts=opts.AxisTickOpts(is_show=True),
|
|
|
+ splitline_opts=opts.SplitLineOpts(is_show=True),
|
|
|
+ offset=10
|
|
|
+ ),
|
|
|
+ xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=True, offset=10),
|
|
|
+
|
|
|
+ )
|
|
|
+ line.render("test.html")
|
|
|
+
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
A = Analysis()
|
|
|
A.analysis_videos()
|
|
|
- print(json.dumps(A.out_put, ensure_ascii=False, indent=4))
|
|
|
+ result_data = A.out_put
|
|
|
+ D = Drawer(result_data)
|
|
|
+ D.draw_line()
|