用python+django+pyecharts制作数据可视化大屏

用python+django+pyecharts制作数据可视化大屏_第1张图片

随着信息化技术在政府、企业管理上应用的进一步发展,大数据技术兴起,数据可视化大屏随之进进入大众视线。下面是用python+django+pyecharts实现大屏的演示。

1,view.py

def pie(request):
    # r = redis.StrictRedis(host='127.0.0.1', port=6379, decode_responses=True)
    # piexs=r.hgetall(name='computer_total_redis')
    # if r.hlen(name="computer_total_redis"):
    #     piex = [[key, int(value)] for key,value in piexs.items()]
    #     #print('hello',piex)
        # test rose pie for May
    piex = [["身体因素","0.0232"],["知识水平、经验","0.0234"],["恶劣天气","0.0312"],["人员品质","0.0316"],["弃渣堆放","0.0316"],["消防设施","0.0317"],["半封闭作业","0.0328"],["盖挖施工技术","0.0397"]]
          #     ["周边荷载","0.0419"],["安全意识","0.0450"],["钢支撑技术","0.0667"],["道路交通","0.0729"],["周边重要建筑","0.0785"],["地连墙设计","0.0817"],["地下管线","0.0936"],["永久支撑","0.1305"],["不良地质","0.1441"]]

        #test end

    # else:
    #     print('world')
    return JsonResponse(json.loads(pie_base(piex)))
    
def pie_base(piex) -> Pie:

    p = (
        Pie(init_opts=opts.InitOpts(bg_color="#0A1B2A"))
            .add('', piex,radius=["20%","80%"])
            .set_global_opts(title_opts=opts.TitleOpts(title='饼图'))  # 设置标题
            .dump_options_with_quotes()
    )

  #.add('', piex,rosetype='area',radius=["20%","80%"])     ##玫瑰图
    return p

2. urls.py

urlpatterns = [
      path('echarts', pyechart.echarts, name='echarts'),
      path('bar/', pyechart.bar, name='bar'),
      path('pie/', pyechart.pie, name='pie'),
]

3. html

    

4. javascript

你可能感兴趣的:(django,python,pycharm)