一、获取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. [x] 封装、继承,多态

    那么多态的作用是什么呢,封装可以使得代码模块化,继承可以扩展已存在的代码,他们的目的都是为了代码重用. 而多态的目的则是为了接口重用.也就是说,不论传递过来的究竟是那个类的对象,函数都能够通过同一个接 ...

  2. laravel Eloquent 查询数据库判断获取的内容是否为空

    原文地址:https://www.cnblogs.com/love-snow/articles/7205338.html 在使用 Laravel Eloquent 模型时,我们要判断取出的结果集是否为 ...

  3. Win10系列:UWP界面布局进阶2

    为了让用户可以在流畅浏览应用界面的同时提供与应用相关的功能按钮,Windows 10系统在用户界面当中引入了侧边栏,侧边栏可以在用户有需要对应用或者系统进行操作时显示,在没有需要操作的时候自动隐藏,并 ...

  4. spoj220

    题解: 后缀数组 把所有串连接起来 二分答案 代码: #include<cstdio> #include<cstring> #include<algorithm> ...

  5. day15-python常用内置模块的使用

    在日常的开发工作中,我们要写很多的python代码,如果都写在一个文件中,会导致代码特别难维护,为了拓展代码的可维护性,我们把函写在不同的文件里,这样每个文件包含的文件就比较少,逻辑更加清楚.在pyt ...

  6. day23 模块02

    核能来袭--模块 2 1.nametuple() 2.os模块 3.sys模块(重点) 4.序列化 (四个函数) 5.pickle(重点) 6.json(重点中的重点) 1.nametuple() 命 ...

  7. SpringMVC:后台将List转为Json,传值到页面

    一.JSP页面 <body> <form name="test" action="getAllStudent" method="po ...

  8. 删除Mac OS X中Finder文件打开方式列表的重复程序或失效的

    清理列表, 可以在终端中输入下面提供的一行命令: /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices ...

  9. :装饰者模式--Beverage

    #ifndef __BEVERAGE_H__ #define __BEVERAGE_H__ #include <string> using namespace std; class Bev ...

  10. 深入理解java虚拟机---jdk8新特性(二)

    1.jdk8新特性 1.新特性 2.lambda函数表达式的作用 A: 替换内部类 B:对集合的操作并行化