深圳市浩天建设网站,棋牌网站代理,公司网站注册要多少钱,北京南站是高铁站吗目录 一、echarts
1、下载
2、配置 二、实现统计分析页面--架构和柱图
1、url
2、chart.py
3、chart_list.html
4、修改url
5、新增chart_bar方法
6、修改chart_list.html
四、饼图
1、url 2、视图chart.py新增
3、修改chart_list.html 五、折线图
1、url
2、char…目录 一、echarts
1、下载
2、配置 二、实现统计分析页面--架构和柱图
1、url
2、chart.py
3、chart_list.html
4、修改url
5、新增chart_bar方法
6、修改chart_list.html
四、饼图
1、url 2、视图chart.py新增
3、修改chart_list.html 五、折线图
1、url
2、chart.py新增
3、chart_list.html 接上一篇《django项目实战九djangobootstrap实现增删改查进阶ajax实现》 知识点 1、饼图、柱图、折线图 一、echarts
1、下载
链接https://pan.baidu.com/s/1CDHwRrofeH5rKfzgCLR0qg 提取码关注联系博主
2、配置 二、实现统计分析页面--架构和柱图
1、url 2、chart.py
from django.shortcuts import renderdef chart_list(request):统计分析return render(request, chart_list.html)3、chart_list.html
这里以柱图为例子定义一个div 、 设置高度、宽度ID重要【下面js要使用】
div idm2 stylewidth: 600px;height: 400px;/div 这个是导入js和柱图官方网站复制 {% extends layout.html %}
{% load static %}
{% block title %}title统计分析/title
{% endblock %}
{% block content %}div classcontainerdiv classpanel panel-defaultdiv classpanel-heading折线图/divdiv classpanel-bodyzhe/div/divdiv classrowdiv classcol-sm-8div classpanel panel-defaultdiv classpanel-heading柱状图/divdiv classpanel-bodydiv idm2 stylewidth: 600px;height: 400px;/div/div/div/divdiv classcol-sm-4div classpanel panel-defaultdiv classpanel-heading饼图/divdiv classpanel-bodyPanel content/div/div/div/div/div{% endblock %}{% block js %}script src{% static js/echarts.min.js %}/scriptscript typetext/javascript// 基于准备好的dom初始化echarts实例var myChart echarts.init(document.getElementById(m2));// 指定图表的配置项和数据var option {title: {text: ECharts 入门示例},tooltip: {},legend: {data: [销量, 价格]},xAxis: {data: [1月, 2月, 3月, 4月, 5月, 6月]},yAxis: {},series: [{name: 销量,type: bar,data: [5, 20, 36, 10, 10, 20]},{name: 价格,type: bar,data: [25, 40, 80, 65, 70, 50]}]};// 使用刚指定的配置项和数据显示图表。myChart.setOption(option);/script
{% endblock %} 4、修改url 5、新增chart_bar方法
from django.shortcuts import render
from django.http import JsonResponsedef chart_list(request):统计分析 页面return render(request, chart_list.html)def chart_bar(request): 构造柱状图的数据 # 数据可以去数据库中获取legend [销量, 价格]xAxis [1月, 2月, 3月, 4月, 5月, 6月]series_list [{name: 销量,type: bar,data: [5, 20, 36, 10, 10, 20]},{name: 价格,type: bar,data: [25, 40, 80, 65, 70, 50]}]result {status: True,data: {legend: legend,xAxis: xAxis,series_list: series_list,}}return JsonResponse(result)
6、修改chart_list.html
{% extends layout.html %}
{% load static %}
{% block title %}title统计分析/title
{% endblock %}
{% block content %}div classcontainerdiv classpanel panel-defaultdiv classpanel-heading折线图/divdiv classpanel-bodyzhe/div/divdiv classrowdiv classcol-sm-8div classpanel panel-defaultdiv classpanel-heading柱状图/divdiv classpanel-bodydiv idm2 stylewidth: 100%;height: 400px;/div/div/div/divdiv classcol-sm-4div classpanel panel-defaultdiv classpanel-heading饼图/divdiv classpanel-bodyPanel content/div/div/div/div/div{% endblock %}{% block js %}script src{% static js/echarts.min.js %}/script
script typetext/javascript$(function () {initBar();})function initBar() {// 基于准备好的dom初始化echarts实例var myChart echarts.init(document.getElementById(m2));// 指定图表的配置项和数据var option {title: {text: 任务,// subtext: xxx公司, //副标题textAlign: auto,left: center,},tooltip: {},legend: {data: [], // 后台获取bottom: 0,},xAxis: {data: [] // 后台获取},yAxis: {},series: [] // 后台获取};$.ajax({url: /chart/bar/,type: get,dataType: JSON,success: function(res){if(res.status){// 将获取到的数据更新到 option 中option.legend.data res.data.legend;option.xAxis.data res.data.xAxis;option.series res.data.series_list;// 使用刚指定的配置项和数据显示图表。myChart.setOption(option);}}})}
/script{% endblock %}
四、饼图
1、url 2、视图chart.py新增
from django.shortcuts import render
from django.http import JsonResponsedef chart_list(request):统计分析 页面return render(request, chart_list.html)def chart_bar(request): 构造柱状图的数据 # 数据可以去数据库中获取legend [销量, 价格]xAxis [1月, 2月, 3月, 4月, 5月, 6月]series_list [{name: 销量,type: bar,data: [5, 20, 36, 10, 10, 20]},{name: 价格,type: bar,data: [25, 40, 80, 65, 70, 50]}]result {status: True,data: {legend: legend,xAxis: xAxis,series_list: series_list,}}return JsonResponse(result)def chart_pie(request): 构造饼图的数据 data_list [{value: 248, name: P0},{value: 735, name: P1},{value: 580, name: P2},{value: 180, name: P3},]result {status: True,data_list: data_list,}return JsonResponse(result)3、修改chart_list.html
{% extends layout.html %}
{% load static %}
{% block title %}title统计分析/title
{% endblock %}
{% block content %}div classcontainerdiv classpanel panel-defaultdiv classpanel-heading折线图/divdiv classpanel-bodyzhe/div/divdiv classrowdiv classcol-sm-8div classpanel panel-defaultdiv classpanel-heading柱状图/divdiv classpanel-bodydiv idm2 stylewidth: 100%;height: 400px;/div/div/div/divdiv classcol-sm-4div classpanel panel-defaultdiv classpanel-heading饼图/divdiv classpanel-bodydiv idm3 stylewidth: 100%;height: 400px;/div/div/div/div/div/div{% endblock %}{% block js %}script src{% static js/echarts.min.js %}/script
script typetext/javascript$(function () {initBar();iniPie();})function initBar() {// 基于准备好的dom初始化echarts实例var myChart echarts.init(document.getElementById(m2));// 指定图表的配置项和数据var option {title: {text: 任务,// subtext: xxx公司, //副标题textAlign: auto,left: center,},tooltip: {},legend: {data: [], // 后台获取bottom: 0,},xAxis: {data: [] // 后台获取},yAxis: {},series: [] // 后台获取};$.ajax({url: /chart/bar/,type: get,dataType: JSON,success: function(res){if(res.status){// 将获取到的数据更新到 option 中option.legend.data res.data.legend;option.xAxis.data res.data.xAxis;option.series res.data.series_list;// 使用刚指定的配置项和数据显示图表。myChart.setOption(option);}}})}// 饼图function iniPie() {var chartDom document.getElementById(m3);var myChart echarts.init(chartDom);var option;option {title: {text: 用例优先级,subtext: xxx公司,left: center},tooltip: {trigger: item},legend: {orient: vertical,bottom: 0,},series: [{name: Access From,type: pie,radius: 50%,data: [],emphasis: {itemStyle: {shadowBlur: 10,shadowOffsetX: 0,shadowColor: rgba(0, 0, 0, 0.5)}}}]};$.ajax({url: /chart/pie/,type: get,dataType: JSON,success: function(res) {if(res.status){option.series[0].data res.data_list;option myChart.setOption(option);}}})
}/script{% endblock %} 五、折线图
1、url 2、chart.py新增
def chart_line(request): 构造折线图的数据 legend_list [2021, 2022]xAxis_list [1月, 2月, 3月, 4月, 5月, 6月, 7月]series_list [{name: 2021,type: line,stack: Total,data: [120, 132, 101, 134, 90, 230, 210]},{name: 2022,type: line,stack: Total,data: [220, 182, 191, 234, 290, 330, 310]},]result {status: True,data: {legend_list: legend_list,xAxis_list: xAxis_list,series_list: series_list,}}return JsonResponse(result)3、chart_list.html
{% extends layout.html %}
{% load static %}
{% block title %}title统计分析/title
{% endblock %}
{% block content %}div classcontainerdiv classpanel panel-defaultdiv classpanel-heading折线图/divdiv classpanel-bodydiv idm1 stylewidth: 100%;height: 250px;/div/div/divdiv classrowdiv classcol-sm-8div classpanel panel-defaultdiv classpanel-heading柱状图/divdiv classpanel-bodydiv idm2 stylewidth: 100%;height: 400px;/div/div/div/divdiv classcol-sm-4div classpanel panel-defaultdiv classpanel-heading饼图/divdiv classpanel-bodydiv idm3 stylewidth: 100%;height: 400px;/div/div/div/div/div/div{% endblock %}{% block js %}script src{% static js/echarts.min.js %}/script
script typetext/javascript$(function () {initBar();iniPie();initLine();})function initBar() {// 基于准备好的dom初始化echarts实例var myChart echarts.init(document.getElementById(m2));// 指定图表的配置项和数据var option {title: {text: 任务,// subtext: xxx公司, //副标题textAlign: auto,left: center,},tooltip: {},legend: {data: [], // 后台获取bottom: 0,},xAxis: {data: [] // 后台获取},yAxis: {},series: [] // 后台获取};$.ajax({url: /chart/bar/,type: get,dataType: JSON,success: function(res){if(res.status){// 将获取到的数据更新到 option 中option.legend.data res.data.legend;option.xAxis.data res.data.xAxis;option.series res.data.series_list;// 使用刚指定的配置项和数据显示图表。myChart.setOption(option);}}})}// 饼图function iniPie() {var chartDom document.getElementById(m3);var myChart echarts.init(chartDom);var option;option {title: {text: 用例优先级,subtext: xxx公司,left: center},tooltip: {trigger: item},legend: {orient: vertical,bottom: 0,},series: [{name: Access From,type: pie,radius: 50%,data: [],emphasis: {itemStyle: {shadowBlur: 10,shadowOffsetX: 0,shadowColor: rgba(0, 0, 0, 0.5)}}}]};$.ajax({url: /chart/pie/,type: get,dataType: JSON,success: function(res) {if(res.status){option.series[0].data res.data_list;option myChart.setOption(option);}}})
}// 折线图function initLine() {var chartDom document.getElementById(m1);var myChart echarts.init(chartDom);var option;option {title: {text: 分公司业绩图,left: center,},tooltip: {trigger: axis},legend: {data: [],bottom: 0,},grid: {left: 3%,right: 4%,bottom: 12%,containLabel: true},toolbox: {feature: {// saveAsImage: {}saveAsImage: false,}},xAxis: {type: category,boundaryGap: false,data: []},yAxis: {type: value},series: []};$.ajax({url: /chart/line/,type: get,dataType: JSON,success: function(res) {if(res.status){option.legend.data res.data.legend_list;option.xAxis.data res.data.xAxis_list;option.series res.data.series_list;option myChart.setOption(option);}}})
}/script{% endblock %}
文章转载自: http://www.morning.spqbp.cn.gov.cn.spqbp.cn http://www.morning.hlwzd.cn.gov.cn.hlwzd.cn http://www.morning.xnlj.cn.gov.cn.xnlj.cn http://www.morning.hrpjx.cn.gov.cn.hrpjx.cn http://www.morning.tklqs.cn.gov.cn.tklqs.cn http://www.morning.lmmh.cn.gov.cn.lmmh.cn http://www.morning.bfnbn.cn.gov.cn.bfnbn.cn http://www.morning.yydeq.cn.gov.cn.yydeq.cn http://www.morning.bkppb.cn.gov.cn.bkppb.cn http://www.morning.bcnsl.cn.gov.cn.bcnsl.cn http://www.morning.lngyd.cn.gov.cn.lngyd.cn http://www.morning.yqlrq.cn.gov.cn.yqlrq.cn http://www.morning.mplb.cn.gov.cn.mplb.cn http://www.morning.qgbfx.cn.gov.cn.qgbfx.cn http://www.morning.dwztj.cn.gov.cn.dwztj.cn http://www.morning.nfmlt.cn.gov.cn.nfmlt.cn http://www.morning.mjytr.cn.gov.cn.mjytr.cn http://www.morning.rwmq.cn.gov.cn.rwmq.cn http://www.morning.lxbml.cn.gov.cn.lxbml.cn http://www.morning.myzfz.com.gov.cn.myzfz.com http://www.morning.rjmd.cn.gov.cn.rjmd.cn http://www.morning.cttti.com.gov.cn.cttti.com http://www.morning.hqbk.cn.gov.cn.hqbk.cn http://www.morning.wbrf.cn.gov.cn.wbrf.cn http://www.morning.rbhqz.cn.gov.cn.rbhqz.cn http://www.morning.kgslc.cn.gov.cn.kgslc.cn http://www.morning.mgmqf.cn.gov.cn.mgmqf.cn http://www.morning.txnqh.cn.gov.cn.txnqh.cn http://www.morning.knmby.cn.gov.cn.knmby.cn http://www.morning.qtltg.cn.gov.cn.qtltg.cn http://www.morning.zhishizf.cn.gov.cn.zhishizf.cn http://www.morning.nllst.cn.gov.cn.nllst.cn http://www.morning.krzrg.cn.gov.cn.krzrg.cn http://www.morning.kjgrg.cn.gov.cn.kjgrg.cn http://www.morning.ppbrq.cn.gov.cn.ppbrq.cn http://www.morning.hhzdj.cn.gov.cn.hhzdj.cn http://www.morning.ktnmg.cn.gov.cn.ktnmg.cn http://www.morning.qhnmj.cn.gov.cn.qhnmj.cn http://www.morning.sgnxl.cn.gov.cn.sgnxl.cn http://www.morning.klzdy.cn.gov.cn.klzdy.cn http://www.morning.bpmdr.cn.gov.cn.bpmdr.cn http://www.morning.pqhgn.cn.gov.cn.pqhgn.cn http://www.morning.btqqh.cn.gov.cn.btqqh.cn http://www.morning.nrrzw.cn.gov.cn.nrrzw.cn http://www.morning.mgmyt.cn.gov.cn.mgmyt.cn http://www.morning.cjwkf.cn.gov.cn.cjwkf.cn http://www.morning.xywfz.cn.gov.cn.xywfz.cn http://www.morning.bhpjc.cn.gov.cn.bhpjc.cn http://www.morning.tlrxp.cn.gov.cn.tlrxp.cn http://www.morning.mlwhd.cn.gov.cn.mlwhd.cn http://www.morning.qxmpp.cn.gov.cn.qxmpp.cn http://www.morning.qlckc.cn.gov.cn.qlckc.cn http://www.morning.kdnbf.cn.gov.cn.kdnbf.cn http://www.morning.mcgsq.cn.gov.cn.mcgsq.cn http://www.morning.gpkjx.cn.gov.cn.gpkjx.cn http://www.morning.fjlsfs.com.gov.cn.fjlsfs.com http://www.morning.jbtwq.cn.gov.cn.jbtwq.cn http://www.morning.fgxr.cn.gov.cn.fgxr.cn http://www.morning.mxcgf.cn.gov.cn.mxcgf.cn http://www.morning.rbzd.cn.gov.cn.rbzd.cn http://www.morning.pfntr.cn.gov.cn.pfntr.cn http://www.morning.chxsn.cn.gov.cn.chxsn.cn http://www.morning.qwrb.cn.gov.cn.qwrb.cn http://www.morning.xbptx.cn.gov.cn.xbptx.cn http://www.morning.xwzsq.cn.gov.cn.xwzsq.cn http://www.morning.dmjhp.cn.gov.cn.dmjhp.cn http://www.morning.yhtnr.cn.gov.cn.yhtnr.cn http://www.morning.kgnnc.cn.gov.cn.kgnnc.cn http://www.morning.rqdx.cn.gov.cn.rqdx.cn http://www.morning.jfmyt.cn.gov.cn.jfmyt.cn http://www.morning.dhrbj.cn.gov.cn.dhrbj.cn http://www.morning.qttft.cn.gov.cn.qttft.cn http://www.morning.zwtp.cn.gov.cn.zwtp.cn http://www.morning.twfdm.cn.gov.cn.twfdm.cn http://www.morning.rkjz.cn.gov.cn.rkjz.cn http://www.morning.skbhl.cn.gov.cn.skbhl.cn http://www.morning.lsgjf.cn.gov.cn.lsgjf.cn http://www.morning.diuchai.com.gov.cn.diuchai.com http://www.morning.fnpyk.cn.gov.cn.fnpyk.cn http://www.morning.mtzyr.cn.gov.cn.mtzyr.cn