生成图片优化

parent 82e9a4c1
......@@ -7,6 +7,8 @@ from app.api.engine import work_dir, pdf_folder, template_folder
from app.service.portfolio_diagnose import PortfolioDiagnose
from app.service.result_service_v2 import UserCustomerResultAdaptor
import numpy as np
from concurrent import futures
import os
# 准备数据
from app.utils.draw import draw_month_return_chart, draw_contribution_chart, draw_combination_chart, \
......@@ -139,13 +141,23 @@ class DataIntegrate:
self.propose_fund_data_list = []
propose_fund_evaluation = self.portfolio_diagnose.propose_fund_evaluation()
propose_radar_chart_data = self.portfolio_diagnose.propose_fund_radar()
with futures.ProcessPoolExecutor(os.cpu_count()) as executor:
res = executor.map(gen_radar_chart, propose_radar_chart_data)
res = list(res)
for i in range(len(propose_fund_evaluation)):
self.propose_fund_data_list.append({
'fund_name': propose_fund_evaluation[i]['name'],
'status': '增仓',
'evaluation': propose_fund_evaluation[i]['data'],
'radar_chart_path': gen_radar_chart(propose_radar_chart_data[i])
'radar_chart_path': res[i]
})
# for i in range(len(propose_fund_evaluation)):
# self.propose_fund_data_list.append({
# 'fund_name': propose_fund_evaluation[i]['name'],
# 'status': '增仓',
# 'evaluation': propose_fund_evaluation[i]['data'],
# 'radar_chart_path': gen_radar_chart(propose_radar_chart_data[i])
# })
def objectives_performance(self, group_result):
"""目标与业绩"""
......
......@@ -19,6 +19,8 @@ import uuid
import cv2
from app.api.engine import work_dir
import numpy as np
from snapshot_phantomjs import snapshot
from pyecharts.render import make_snapshot
def gen_radar_chart(radar_chart_data):
......@@ -73,6 +75,11 @@ def gen_radar_chart(radar_chart_data):
}),
legend_opts=opts.LegendOpts(selected_mode=False, is_show=False)
)
# radar.render("basic_radar_chart.html")
# img_content = work_dir + "/app/html/{}.png".format(str(uuid.uuid4()))
# make_snapshot(snapshot, "basic_radar_chart.html", img_content, delay=2)
html = radar.render_embed()
start = time.time()
image_bin = imgkit.from_string(html, None)
......
......@@ -68443,3 +68443,83 @@ FROM ifa_customer
WHERE ifa_customer.ifa_id = %(ifa_id_1)s
2020-12-07 18:39:11 Mon sqlalchemy.engine.base.Engine INFO {'ifa_id_1': 'USER_INFO15916074199322'}
2020-12-07 18:39:11 Mon sqlalchemy.engine.base.Engine INFO COMMIT
2020-12-08 14:41:40 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:41:41 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:41:41 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:41:48 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/7061fb02-2c88-4360-9f9f-53d5348f0649t.png
2020-12-08 14:41:48 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:41:48 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:41:48 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:41:55 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/163bd285-dfb2-4a34-a365-f25daa9903f0t.png
2020-12-08 14:41:56 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:41:56 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:41:56 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:42:03 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/5babc6d9-9fe1-45c5-bfcf-1de7d5315f2bt.png
2020-12-08 14:42:03 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:42:03 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:42:03 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:42:08 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/85bcc7df-0546-4649-a481-75457b004fd1t.png
2020-12-08 14:42:09 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:42:09 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:42:09 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:42:17 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/968178d7-7d55-4daa-8504-5429b4f640c3t.png
2020-12-08 14:42:17 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:42:17 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:42:17 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:42:23 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/77e6e5cb-fe0d-482c-8e97-c6425c641ec7t.png
2020-12-08 14:42:23 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:42:23 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:42:23 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:42:40 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/d72e11a1-b132-4aa8-b890-659ce8dde3a8t.png
2020-12-08 14:42:40 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:42:40 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:42:40 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:42:45 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/a589a4aa-1e1b-44b4-99cc-fef10e554858t.png
2020-12-08 14:45:26 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:45:26 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:45:26 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:45:35 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/09ae0a04-12d5-47e4-bc97-e10ad02f604b.png
2020-12-08 14:45:35 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:45:35 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:45:35 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:45:48 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/ac603d8d-ace2-4a18-8fcc-e6f8386aa5d4.png
2020-12-08 14:45:49 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:45:49 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:45:49 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:45:57 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/99759ada-93d4-4063-bdf1-fd8922c7e750.png
2020-12-08 14:45:57 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:45:57 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:45:57 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:46:04 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/4c16f5df-a8ee-47fd-8bfc-13295ec194d9.png
2020-12-08 14:46:04 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:46:04 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:46:04 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:46:13 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/b7aa1949-8665-4e39-8404-d439df7cc7a9.png
2020-12-08 14:46:13 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:46:13 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:46:13 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:46:27 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/e0028133-0145-4bd2-80d9-8316df17f78b.png
2020-12-08 14:46:27 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:46:27 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:46:27 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:46:34 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/54132728-2e62-4060-8fd2-c6f9487980a9.png
2020-12-08 14:46:34 Tue pyecharts.render.snapshot INFO Generating file ...
2020-12-08 14:46:34 Tue snapshot_phantomjs.snapshot INFO phantomjs version: 2.1.1
2020-12-08 14:46:34 Tue snapshot_phantomjs.snapshot INFO Generating file ...
2020-12-08 14:46:41 Tue pyecharts.render.snapshot INFO File saved in /Users/pengxiong/Desktop/fund_report/app/html/1f869841-2090-47ae-9c9d-94e6a514e390.png
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment