456

parent 92f5f387
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -6,11 +6,14 @@
# @Email : acepengxiong@163.com
# @Software : PyCharm
# -----------------------------------------------------------------------------
from io import BytesIO, StringIO
import imgkit
import pyecharts.options as opts
from pyecharts.charts import Radar, Bar
from snapshot_phantomjs import snapshot
from pyecharts.render import make_snapshot
import cv2
def gen_radar_chart():
......@@ -21,11 +24,9 @@ def gen_radar_chart():
1、雷达图周围的图例的 textStyle 暂时无法设置背景颜色
"""
v1 = [[4300, 10000, 28000, 35000, 50000]]
(
Radar(
init_opts=opts.InitOpts(bg_color="#fff", animation_opts=opts.AnimationOpts(animation=False)))
.add_schema(
htmldata = StringIO()
radar = Radar(
init_opts=opts.InitOpts(bg_color="#fff", animation_opts=opts.AnimationOpts(animation=False))).add_schema(
schema=[
opts.RadarIndicatorItem(name="绝对收益", max_=6500),
opts.RadarIndicatorItem(name="业绩持续性", max_=16000),
......@@ -43,15 +44,12 @@ def gen_radar_chart():
])
),
textstyle_opts=opts.TextStyleOpts(color="#000", font_size=16),
)
.add(
).add(
series_name="预算分配(Allocated Budget)",
data=v1,
linestyle_opts=opts.LineStyleOpts(width=2, color="#C6A774"),
tooltip_opts=None
)
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(
).set_series_opts(label_opts=opts.LabelOpts(is_show=False)).set_global_opts(
title_opts=opts.TitleOpts(
title="综合评分", subtitle="66.32", pos_top="center", pos_left="46%",
title_textstyle_opts={'color': '#333',
......@@ -66,10 +64,21 @@ def gen_radar_chart():
}),
legend_opts=opts.LegendOpts(selected_mode=False, is_show=False)
)
.render("basic_radar_chart.html")
)
make_snapshot(snapshot, "basic_radar_chart.html", "basic_radar_chart.png", delay=2)
radar.render()
imgkit.from_file('render.html', "radar_chart.png")
# 读取图片
img = cv2.imread('radar_chart.png')
# 获取宽度和高度
height = len(img)
width = len(img[0])
img = img[height:height, 200:800]
height = len(img)
width = len(img[0])
print('图片大小%dX%d' % (width, height))
cv2.imshow('radar_chart.png', img)
cv2.waitKey(0)
if __name__ == '__main__':
gen_radar_chart()
\ No newline at end of file
from jinja2 import PackageLoader, Environment
from app.service.result_service import UserCustomerResultAdaptor
import numpy as np
# 准备数据
from app.utils.draw import draw_month_return_chart, draw_contribution_chart
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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