一、获取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. 学习笔记-AngularJs(三)

    学习笔记-AngularJs(二)写了个所有程序语言入门时都必须要写的Hello World,那么从现在开始做那个之前说过的互联网大佬介绍的学习例子,当然这里开始会慢慢按照之前说过的目录来搭建这个学习 ...

  2. 【基础】selenium中元素定位的常用方法(三)

    一.Selenium中元素定位共有八种 id name className tagName linkText partialLinkText xpath cssSelector 其中前六种都比较简单, ...

  3. linux nginx 安装防火墙ngx_lua_waf

    ngx_lua_waf是一款开源的 基于 ngx_lua的 web应用防火墙 github地址是  https://github.com/loveshell/ngx_lua_waf 安装流程如下 1 ...

  4. Unity中Button按钮的触发监听事件

    第一种方式:需要把自己添加的Button按钮属性(Inspector)中的(Button)onclick添加方法. public void BtnCreteClick() { Debug.Log(&q ...

  5. 泛型算法,排序的相关操作,lower_bound、upper_bound、equal_range

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...

  6. vue-11-自定义指令

    用于对纯 DOM 元素进行底层操作. // 注册一个全局自定义指令 v-focus Vue.directive('focus', { // 当绑定元素插入到 DOM 中. inserted: func ...

  7. 关于这次安装Oracle

    前后大概经历了一个星期,今天下午(先是用的Navicat)当我尝试性的把用户名上方的复选项从服务名换成SID时,竟然瞬间连接成功了,整个人都是蒙B的,这样就好了? 之后我又用PLsql测试了一下,秒进 ...

  8. unity3d 九宫密码锁

    using UnityEngine;using System.Collections.Generic;using System;using UnityEngine.EventSystems;using ...

  9. SparkStreaming实时日志分析--实时热搜词

    Overview 整个项目的整体架构如下: 关于SparkStreaming的部分: Flume传数据到SparkStreaming:为了简单使用的是push-based的方式.这种方式可能会丢失数据 ...

  10. C++中数组定义及初始化

    一.一维数组 静态 int array[100]; 定义了数组array,并未对数组进行初始化 静态 int array[100] = {1,2}: 定义并初始化了数组array 动态 int* ar ...