由testcase数据之分析
一、获取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数据之分析的更多相关文章
- 《Wireshark数据包分析实战》 - http背后,tcp/ip抓包分析
作为网络开发人员,使用fiddler无疑是最好的选择,方便易用功能强. 但是什么作为爱学习的同学,是不应该止步于http协议的,学习wireshark则可以满足这方面的需求.wireshark作为抓取 ...
- iOS开发——项目实战总结&数据持久化分析
数据持久化分析 plist文件(属性列表) preference(偏好设置) NSKeyedArchiver(归档) SQLite 3 CoreData 当存储大块数据时你会怎么做? 你有很多选择,比 ...
- WireShark数据包分析数据封装
WireShark数据包分析数据封装 数据封装(Data Encapsulation)是指将协议数据单元(PDU)封装在一组协议头和尾中的过程.在OSI七层参考模型中,每层主要负责与其它机器上的对等层 ...
- 可视化数据包分析工具-CapAnalysis
可视化数据包分析工具-CapAnalysis 我们知道,Xplico是一个从pcap文件中解析出IP流量数据的工具,本文介绍又一款实用工具-CapAnalysis(可视化数据包分析工具),将比Xpli ...
- snmp数据包分析
今天看了一下snmp数据包的报文格式,用wireshark抓了两个数据包来分析. 先说说snmp get-request的书报包格式吧,get-next-request,get-response,se ...
- ajax对一些没有接口的数据进行分析和添加方法
对于一些没有接口的数据进行分析和添加方法: <script src="ajax.js"><script>//插入ajax文件 <script> ...
- tcprstat源码分析之tcp数据包分析
tcprstat是percona用来监测mysql响应时间的.不过对于任何运行在TCP协议上的响应时间,都可以用.本文主要做源码分析,如何使用tcprstat请大家查看博文<tcprstat分析 ...
- 第二篇:智能电网(Smart Grid)中的数据工程与大数据案例分析
前言 上篇文章中讲到,在智能电网的控制与管理侧中,数据的分析和挖掘.可视化等工作属于核心环节.除此之外,二次侧中需要对数据进行采集,数据共享平台的搭建显然也涉及到数据的管理.那么在智能电网领域中,数据 ...
- firebug登陆之数据包分析
登陆之数据包分析 工具: python-urllib2 | firefox+firebug或者chrome,用浏览器打开登陆页面之后,按F12键会默认打开开发者工具或者启动firebug,点击n ...
随机推荐
- beamer template
\setbeamercolor{postit}{fg=black,bg=white} \begin{beamercolorbox}[rounded=true,shadow=true, sep=0em, ...
- read later
https://groups.google.com/forum/#!msg/pylearn-users/FYtpaQKoC4c/ubitO_JUC1kJ 网上论坛 发布回复 ...
- Win10系列:JavaScript动画4
上面介绍的动画效果是通过Windows动画库创建的,这里的旋转动画是通过设置页面元素的style对象的相关属性来创建,此动画的效果是将界面元素沿着指定的方向进行旋转.下面介绍style对象的几个常用属 ...
- Date和Timestamp区别
主要是精度问题,date没有ms,而timestamp是有ms的,所以date的精度要低于timestamp. 而且二者可以互相转换. 除此之外,没有什么不同,
- nginx:负载均衡实战(一)
1.负载均衡说明 2.准备 我自己在电脑布置了两台虚拟机,两台都有nginx和tomcat,两台虚拟机布置的ip分别是37以及54,我在tomcat的首页动了点手脚,方便自己看是来自哪个ip的 接着在 ...
- bs4 CSS选择器
#https://www.crummy.com/software/BeautifulSoup/bs4/doc/index.zh.html#find-all #beautifulSoup可以解析HTML ...
- Cracking The Coding Interview5.2
//Given a (decimal - e.g. 3.72) number that is passed in as a string, print the binary representatio ...
- js 冒泡事件阻止 父层事件影响子层
当父层 与子层 有相同的事件时,但子层跟父层执行的内容却不一样时 为了 防止 父层事件对子层造成影响我们可以在子层的方法里做如下操作 function A (event){ event.stopPro ...
- DevExpress WinForms使用教程:WinForms Sunburst控件
[DevExpress WinForms v18.2下载] DevExpress WinForms v18.2中包含了一个新的WinForms组件 - WinForms Sunburst,它旨在帮助开 ...
- MyEclipse和Eclipse
Eclipse 分成3个子项目: ·平台Platform ·开发工具箱-Java Development Toolkit(JDT) ·外挂开发环境-Plug-in Development Enviro ...