一、获取data来源

  1、利用openpyxl从excel表格获取数据,相较于xlrd,openpyxl可以将表格里的样式也传递过来的优势

xlrd  -----------------     https://blog.csdn.net/csdnnews/article/details/80878945

openpyxl  ---------------  https://www.cnblogs.com/zeke-python-road/p/8986318.html

from openpyxl import load_workbook
from matplotlib import pyplot as plt wb = load_workbook('qqqqqq.xlsx')
ws = wb.active cols = []
for col in ws.iter_cols():
col = col[:]
cols.append(col) Casename_list = []
for key in cols[]:
Casename_list.append(key.value)
# print(Casename_list) Test_result = []
for key in cols[]:
Test_result.append(key.value)

二、data图表分析

  1、利用matplotlab

  存在中文编码问题:

import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号 plt.plot((,,),(,,))
plt.xlabel('横坐标')
plt.ylabel('纵坐标')
plt.show()
---------------------
作者:Yrish
来源:CSDN
原文:https://blog.csdn.net/sinat_29699167/article/details/80029898
版权声明:本文为博主原创文章,转载请附上博文链接!

  2、echarts    -----    https://www.cnblogs.com/a10086/p/9551966.html

    A、后台拼凑数据

class Echarts_html(TemplateView):
template_name = "templeate/app01/echarts.html" def get_context_data(self, **kwargs):
context = super(Echarts_html, self).get_context_data(**kwargs)
aaa= {
'title': {
'text': 'ECharts 入门示例'
},
'tooltip': {},
'legend': {
'data': ['销量']
},
'xAxis': {
'data': []
},
'yAxis': {},
'series': [{
'name': '销量',
'type': 'bar',
'data': []
}]
}
articles = Article.objects.all()
for item in articles:
aaa['xAxis']['data'].append(item.title)
aaa['series'][]['data'].append(item.read_count)
context['aaa'] = aaa
return context

  前台代码,数据处理完毕,前台直接使用。但是记得加{{xxx|safe}} 否则会被转义(xss跨站了解下)

<body>
  <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main')); // 指定图表的配置项和数据
var option = {{ aaa | safe}};
myChart.setOption(option);
</script>
</body>

  3、前台js处理数据 

class Echarts_html(TemplateView):
template_name = "templeate/app01/echarts.html" def get_context_data(self, **kwargs):
context = super(Echarts_html, self).get_context_data(**kwargs)
context['articles'] = Article.objects.all()
return context

前台代码,js处理,注意的一点就是js中数组push(类似append)必须是字符串或者数字,直接"xxxx"转成字符串。

<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main')); // 指定图表的配置项和数据
var option = {
'title': {
'text': 'ECharts 入门示例'
},
'tooltip': {},
'legend': {
'data': ['阅读量']
},
'xAxis': {
'data': []
},
'yAxis': {},
'series': [{
'name': '阅读量',
'type': 'bar',
'data': []
}]
}
{% for item in articles %}
option['xAxis']['data'].push("{{ item.title }}")
option['series'][]['data'].push("{{ item.read_count }}")
{% endfor %}
console.log(option) // 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script> </body>

三、eg

  1、前台

from django.views.generic.base import TemplateView
from .models import *
class Echarts_html(TemplateView):
template_name = "../templates/eg1.html"
def get_context_data(self, **kwargs):
context = super(Echarts_html, self).get_context_data(**kwargs)
aaa = {
'title': {
'text': 'ECharts 测试示例'
},
'tooltip': {},
'legend': {
'data': ['销量']
},
'xAxis': {
'data': []
},
'yAxis': {},
'series': [{
'name': '销量',
'type': 'bar',
'data': []
}]
}
articles = Article.objects.all()
for item in articles:
aaa['xAxis']['data'].append(item.name)
aaa['series'][]['data'].append(item.read_count)
context['aaa'] = aaa
return context def post(self,request):
print('post')
return HttpResponse('post')

  2、后台

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcss.com/echarts/4.2.0-rc.2/echarts.js"></script>
</head>
<style>
#myimg {
border: 1px solid red;
height: 18px;
width: 18px;
background-image: url('2.png');
background-position-y: 138px;
}
</style>
<body> <form action="" method="post">
<input type="text">
<input type="submit" value="带点"> </form> <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main')); // 指定图表的配置项和数据
var option = {{ aaa | safe}};
myChart.setOption(option);
</script> </body>
</html>

由testcase数据之分析的更多相关文章

  1. 《Wireshark数据包分析实战》 - http背后,tcp/ip抓包分析

    作为网络开发人员,使用fiddler无疑是最好的选择,方便易用功能强. 但是什么作为爱学习的同学,是不应该止步于http协议的,学习wireshark则可以满足这方面的需求.wireshark作为抓取 ...

  2. iOS开发——项目实战总结&数据持久化分析

    数据持久化分析 plist文件(属性列表) preference(偏好设置) NSKeyedArchiver(归档) SQLite 3 CoreData 当存储大块数据时你会怎么做? 你有很多选择,比 ...

  3. WireShark数据包分析数据封装

    WireShark数据包分析数据封装 数据封装(Data Encapsulation)是指将协议数据单元(PDU)封装在一组协议头和尾中的过程.在OSI七层参考模型中,每层主要负责与其它机器上的对等层 ...

  4. 可视化数据包分析工具-CapAnalysis

    可视化数据包分析工具-CapAnalysis 我们知道,Xplico是一个从pcap文件中解析出IP流量数据的工具,本文介绍又一款实用工具-CapAnalysis(可视化数据包分析工具),将比Xpli ...

  5. snmp数据包分析

    今天看了一下snmp数据包的报文格式,用wireshark抓了两个数据包来分析. 先说说snmp get-request的书报包格式吧,get-next-request,get-response,se ...

  6. ajax对一些没有接口的数据进行分析和添加方法

    对于一些没有接口的数据进行分析和添加方法: <script src="ajax.js"><script>//插入ajax文件 <script> ...

  7. tcprstat源码分析之tcp数据包分析

    tcprstat是percona用来监测mysql响应时间的.不过对于任何运行在TCP协议上的响应时间,都可以用.本文主要做源码分析,如何使用tcprstat请大家查看博文<tcprstat分析 ...

  8. 第二篇:智能电网(Smart Grid)中的数据工程与大数据案例分析

    前言 上篇文章中讲到,在智能电网的控制与管理侧中,数据的分析和挖掘.可视化等工作属于核心环节.除此之外,二次侧中需要对数据进行采集,数据共享平台的搭建显然也涉及到数据的管理.那么在智能电网领域中,数据 ...

  9. firebug登陆之数据包分析

    登陆之数据包分析 工具: python-urllib2   |  firefox+firebug或者chrome,用浏览器打开登陆页面之后,按F12键会默认打开开发者工具或者启动firebug,点击n ...

随机推荐

  1. jquery radio使用

    var list= $('input:radio[name="list"]:checked').val();

  2. Daily record-July

    July11. Nonsense! 胡说八道!2. Who cares! 谁管你呀!3. It's on me.. 我来付.4. It's a deal. 一言为定.5. I've done my b ...

  3. day06_python_1124

    01 昨日内容回顾 字典: 增: setdefault() 有责不变,无责添加 dic['key'] = vaulue 删: pop 按照key pop('key') pop('key',None) ...

  4. java新随笔

    1.纯随机数发生器 Xn+1=(aXn + c)mod m Modulus=231-1=int.MaxValue Multiplier=75=16807 C=0 当显示过2^31-2个数之后,才可能重 ...

  5. Android system :led_class驱动

    一.代码: leds_4412.c #include <linux/kernel.h> #include <linux/module.h> #include <linux ...

  6. vivado对task和function的可综合支持

    手册UG901,对vivado可综合的语句支持进行了描述,HDL包括:verilog-2001,system-verilog,VHDL: verilog-2001扩展了对task和function的支 ...

  7. Java作业四

    1.先在一个包中编写第一个类ClassA,要求该类中具有四种不同访问权限的成员,再在另一个包中编写第二个类ClassB,并在该类中编写一个方法以访问第一个类中的成员.总结类成员访问控制的基本规则. p ...

  8. 异常 No module named 'numpy.core._multiarray_umath

    No module named 'numpy.core._multiarray_umath 解决方法: 1. 可能是由于模型保存时出错,导致模型没有保存成功,此时删掉保存的模型即可 2. numpy版 ...

  9. VC 任务栏图标闪烁

    像QQ来消息时的,图标闪烁效果 将如下代码添加到Timer响应函数中 ) {// 任务栏图标闪烁 if (this != GetForegroundWindow()) { //// this-> ...

  10. springsecurity的remember me

    基于持久化的token的方法 实现原理:将生成的 token 存入 cookie 中并发送到客户端浏览器,待到下次用户访问系统时,系统将直接从客户端 cookie 中读取 token 进行认证. 实现 ...