读取“员工月度综合评价.xlsx”的文件,使用pyecharts库绘制该文件中每个员工各项能力的雷达图

整体代码如下:

import pandas as pd
data1 = pd.DataFrame(pd.read_excel('员工月度综合评价.xlsx'))
data_radar = []
for row in range(data1.shape[0]):
    dic = {}
    value = []
    for col in range(1,data1.shape[1]):
        value.append(int(data1.iloc[row,col]))
    dic['name'],dic['value'] = data1['员工'][row],value
    data_radar.append([dic])
printf(data_radar )
scope = []
for col in range(1,data1.shape[1]):
    dic = {}
    dic['name'] = data1.columns[col]
    dic['max'],dic['min'] = max(data1.iloc[:,col]),0
    scope.append(dic)
print(scope)
from pyecharts import options as opts
from pyecharts.charts import Radar
from pyecharts.commons.utils import JsCode
 
c = (
      # Radar()
    Radar(init_opts=opts.InitOpts(bg_color={"type": "pattern", "image": JsCode("img"), "repeat": "no-repeat"}))
        .add_js_funcs(    """    var img = new Image();
                          img.src = '背景.jpg';    """)
        .add_schema(
        schema=scope,
        shape="circle",
        center=["50%", "50%"],#宽高:900px*500px
        radius="60%",
        angleaxis_opts=opts.AngleAxisOpts(
            min_=0,
            max_=360,
            is_clockwise=False,
            interval=10,
            axistick_opts=opts.AxisTickOpts(is_show=True),
            axislabel_opts=opts.LabelOpts(is_show=True),
            axisline_opts=opts.AxisLineOpts(is_show=True),
            splitline_opts=opts.SplitLineOpts(is_show=True)
        ),
        radiusaxis_opts=opts.RadiusAxisOpts(
            min_=0,
            max_=30,
            interval=5,
            splitarea_opts=opts.SplitAreaOpts(
                is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)
            ),
        ),
        polar_opts=opts.PolarOpts(),
        splitline_opt=opts.SplitLineOpts(is_show=False)
    )
        .add(
        series_name="许一",
        data=data_radar[0],
        areastyle_opts=opts.AreaStyleOpts(opacity=0.2),
        linestyle_opts=opts.LineStyleOpts(width=2),
        color='#fc5a50'
    )
        .add(
        series_name="刘二",
        data=data_radar[1],
        areastyle_opts=opts.AreaStyleOpts(opacity=0.2),
        linestyle_opts=opts.LineStyleOpts(width=2),
        color='#35ad6b'
    )
        .add(
        series_name="张三",
        data=data_radar[2],
        areastyle_opts=opts.AreaStyleOpts(opacity=0.2),
        linestyle_opts=opts.LineStyleOpts(width=2),
        color='#3d7afd'
    )
        .add(
        series_name="李四",
        data=data_radar[3],
        areastyle_opts=opts.AreaStyleOpts(opacity=0.2),
        linestyle_opts=opts.LineStyleOpts(width=2),
        color='#aa23ff'
    )
        .add(
        series_name="王五",
        data=data_radar[4],
        areastyle_opts=opts.AreaStyleOpts(opacity=0.2),
        linestyle_opts=opts.LineStyleOpts(width=2),
        color='#fcb001'
    )
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(title_opts=opts.TitleOpts(title = '员工评价',subtitle = '',pos_left='left'))
        .render_notebook()
)
print(c)

效果如下:
读取“员工月度综合评价.xlsx”的文件,使用pyecharts库绘制该文件中每个员工各项能力的雷达图_第1张图片

你可能感兴趣的:(python,python,pandas,开发语言)