Echarts多图表动态更新示例

前端框架(html、echarts、jquery)



	
		
		echarts多图表动态更新示例
		
		
	
	
		

后端框架(django)

from django.http import HttpResponse
import json

#饼图
def EchartsPie(request):
    data = []
    names = ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
    values = [50, 20, 36, 10, 10, 20]
    for i in range(len(names)):
        res = {}
        res['name'] = names[i]
        res['value'] = values[i]
        data.append(res)
    return HttpResponse(json.dumps(data), content_type="application/json")

#柱状图
def EchartsBar(request):
    data = {}
    categories = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    values = [50, 20, 36, 10, 10, 20]
    data['categories'] = categories
    data['values'] = values
    return HttpResponse(json.dumps(data), content_type="application/json")

效果展示:

Echarts多图表动态更新示例_第1张图片

你可能感兴趣的:(Django,echarts,前端,javascript)