from pyecharts import options as opts from pyecharts.charts import Radar # 雷达图配置 def radar_chart(): # 雷达图指示器(维度) indicators = [ {"name": "初级岗位", "max": 10000}, {"name": "中级岗位", "max": 20000}, {"name": "高级岗位", "max": 30000}, {"name": "管理岗位", "max": 40000}, {"name": "技术专家", "max": 50000} ] # 系列数据(这里使用示例数据,你可以替换为实际数据) series_data = [ { "value": [5000, 12000, 18000, 25000, 35000], "name": "A公司" }, { "value": [6000, 15000, 22000, 30000, 42000], "name": "B公司" }, { "value": [4500, 10000, 16000, 20000, 30000], "name": "C公司" } ] # 创建雷达图 radar = ( Radar(init_opts=opts.InitOpts(width="800px", height="600px")) .add_schema( schema=indicators, splitarea_opt=opts.SplitAreaOpts(is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)), textstyle_opts=opts.TextStyleOpts(color="#333"), ) .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) .add( series_name="工资水平", data=series_data, linestyle_opts=opts.LineStyleOpts(width=2), areastyle_opts=opts.AreaStyleOpts(opacity=0.1), ) .set_global_opts( title_opts=opts.TitleOpts(title="不同岗位工资水平对比", pos_left="center"), legend_opts=opts.LegendOpts(pos_left="right", orient="vertical"), tooltip_opts=opts.TooltipOpts(trigger="item"), ) ) return radar # 生成图表 chart = radar_chart() chart.render("salary_radar.html")