echarts图片保存
一.js:
function updateChart(versionList,rateList) {
option = {
title: {
text: '拖动频次'
},
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
legend: {
itemWidth:15,
itemHeight:15,
data:['拖动频次[拖动次数/小时]'],
},
animation : false,
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
data : versionList,
axisTick: {
alignWithLabel: true
}
}
],
yAxis : [
{
type : 'value',
name:'次/小时',
axisLabel: {
formatter: '{value}',
}
},
],
series : [
{
name:'拖动频次[拖动次数/小时]',
type:'bar',
barWidth: '50%',
itemStyle:{
normal:{
color:'rgba(58,95,205,1)',
borderType : 'dashed',
barBorderRadius:[10, 10, 10, 10],
}
},
label: {
normal: {
show: true,
position: 'top',
textStyle: {
color: 'black'
}
}
},
data:rateList
}
]
};
chart.setOption(option, true);
var projectId = GetQueryString('projectId');
picLoad(chart.getDataURL(),"/Btm20LCDDragfrequency"+projectId+".png");
}
注意: animation : false, 否则图片不能保存
function picLoad(dataPic,picName){
$.ajax({
type : 'POST',
url : '/ajax/loadPic',
data : {
"data" :dataPic,
"name" : picName
},
contentType : "application/x-www-form-urlencoded",
success : function(data) {
}
});
}
解释:
1.chart.getDataURL()方法获取base64编码,获取的结果是:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABI4AAAEsCAYAAAClh/jbAAA ... 在"base64,"之后的才是图片信息
二.后台
@RequestMapping(value = "/loadPic", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public @ResponseBody Map<String, Object> reg(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> result = new HashMap<String, Object>();
String name = request.getParameter("name");
String[] picData = request.getParameter("data").split(",");
try {
byte[] n = new BASE64Decoder().decodeBuffer(picData[1]);
String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
path = path + "folderPath.properties";
Properties prop = new Properties();
prop.load(new FileInputStream(path));
String filePath = prop.getProperty("UploadPicImagePath");
File fp = new File(filePath);
if (!fp.exists()) {
fp.mkdirs();
}
OutputStream out = new FileOutputStream(new File(filePath+name));
out.write(n);
out.flush();
out.close();
result.put("code", 200);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.info(name+" save success");
return result;
}
三.获取图片
@Override
public boolean sendFingerReport(Integer projectId, Integer versionId, String userGroup,
Btm20LCDEmailConfig emailConfig) throws Exception {
Map<String, Object> emailMap = new HashMap<String, Object>();
// 版本
Version version = this.versionService.getVersionById(versionId);
emailMap.put("version", version);
emailMap.put("projectId", projectId);
String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
path = path + "folderPath.properties";
Properties prop = new Properties();
prop.load(new FileInputStream(path));
String filePath = prop.getProperty("UploadPicImagePath");
File f1 = new File(filePath + "/Btm20LCDAPPBrigthDrag" + projectId + ".png");
if (f1.exists()) {
emailMap.put("Btm20LCDAPPBrigthDrag", filePath + "/Btm20LCDAPPBrigthDrag" + projectId + ".png");
}
// 收件人
String receiver = "";
if (emailConfig != null && !CheckUtils.isNullOrBlank(emailConfig.getReciverId())) {
TmGroup tmGroup = this.tmGroupService.selectTmGroupById(emailConfig.getReciverId());
if (!CheckUtils.isNullOrBlank(tmGroup) && !CheckUtils.isNullOrBlank(tmGroup.getMemberArr())) {
String[] groupMembers = tmGroup.getMemberArr().split(",");
for (int i = 0; i < groupMembers.length; i++) {
receiver += this.personInfoService.selectPersonInfoById(Integer.parseInt(groupMembers[i]))
.getEmail() + ",";
}
}
}
String mailText = templateEmailService.getMailText("/btm20/email/btm20LcdMail.ftl", emailMap);
Email email = new Email();
email.setEmail(true);// 标记收件人是不是邮箱
email.setSubject(emailConfig.getSubject());
email.setTo(receiver);
email.setCc(copyTo);
email.setContent(mailText);
boolean send = EmailServerTerminal.send(email,"btm20");
return send;
}
echarts图片保存的更多相关文章
- Java - PhantomJS + EChartsConvert实现ECharts图片保存到服务端
1.所需工具 1>phantomjs:官网下载http://phantomjs.org/download.html 国内镜像http://npm.taobao.org/dist/phantomj ...
- ECharts外部调用保存为图片操作及工作流接线mouseenter和mouseleave由于鼠标移动速度过快导致问题解决办法
记录两个项目开发中遇到的问题,一个是ECharts外部调用保存为图片操作,一个是workflow工作流连接曲线onmouseenter和onmouseleave事件由于鼠标移动过快触发问题. 一.外部 ...
- php 获取远程图片保存到本地
php 获取远程图片保存到本地 使用两个函数 1.获取远程文件 2.把图片保存到本地 /** * 获取远程图片并把它保存到本地 * $url 是远程图片的完整URL地址,不能为空. */ functi ...
- 用qt代码怎样编写图片保存格式[qt4.6]
用qt代码怎样编写图片保存格式 qt提供了多个保存图片的接口,比较常用的接口如下 bool QPixmap::save ( const QString & fileName, const ch ...
- iOS 将图片保存到本地
//将图片保存到本地 + (void)SaveImageToLocal:(UIImage*)image Keys:(NSString*)key { NSUserDefaults* prefer ...
- C# 图片保存到数据库和从数据库读取图片并显示
图片保存到数据库的方法: public void imgToDB(string sql) { //参数sql中要求保存的imge变量名称为@images //调 ...
- file_put_contents() 图片保存 函数成功之后返回值
今天弄图片保存时,用到file_put_contents()来保存图片,运行了几次,发下一直没有数据出来,以为是这个函数没操作成功 于是查看了下这个函数的用法和返回值,发现我输出的返回都正确,后来才发 ...
- iOS9中将图片保存到照片中的某个相册的方法说明
iOS9中将图片保存到照片中的某个相册的方法说明 在App中很经常遇到的就是用户点击某张图片后将图片保存到本地,下面介绍下iOS中保存图片的一些东西 1.首先,在iOS中把图片保存到系统照片是比较简单 ...
- 24位和8位BMP图片保存纯C代码
BMP图片大家都知道,可以通过查看BMP图片结构使用纯C就可以打开,编辑,处理,保存图片.非常方便使用. 具体BMP结构可以参考:wingdi.h头文件.今天主要在进行删减代码,需要把多余的代码删除, ...
随机推荐
- Windows平台搭建-----C语言
上期我们已经进行Linux的平台搭建,今期我们就来搭建下我们最常用的.最适合初学者的一种方式,那就是搭建Windows平台开发环境,只需要两种工具即可,一个就是编辑器(编辑代码的工具),另一个就是编译 ...
- EJB3.0之事务
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/aboy123/article/details/24586803 一 事务是什么 1 事务的概念 1. ...
- centos7下安装docker(15.1跨主机网络)
之前学习了单个host上的网络,我们知道单个host上的网络有:none,host,bridge和joined,他们解决了单个host上面的容器通信的问题:接下来我们讨论跨主机间容器通信的方案 跨主机 ...
- 关于 chrome canary X64 在 win7 64bit 下面缺少openvr_api.dll的解决方法
在github上下载openvr_api.dll放到chrome的安装目录下就可以. 其实放到系统目录下最好,以后其他程序要使用的时候也能使用的到. https://github.com/ValveS ...
- 在git多分支repo仓库中彻底清除大文件
坑的由来 repo中不小心上传了许多测试生成的data.结果可想而知,原本只有代码的仓库突然间变得无比臃肿(或者是慢慢臃肿),从早期的几十MB,迅速飙升至1G. 到底发生了什么 早些时候我对git的原 ...
- Python 字典方法
访问字典的值 字典中的 键/值 实际上就是一种映射关系,只要知道了 “键”,就肯定知道 “值”. >>> my_dict = dict(name = 'zhangsan',other ...
- [国家集训队]happiness
嘟嘟嘟 就这么建. --- #include<cstdio> #include<iostream> #include<cmath> #include<algo ...
- 90道Python面试题,做对80%直击年薪40w
转发链接: 1.一行代码实现1--100之和 利用sum()函数求和 2.如何在一个函数内部修改全局变量 函数内部global声明 修改全局变量 3.列出5个python标准库 os:提供了不少与操作 ...
- day12--装饰器
定义(如何理解装饰器):装饰器本生是闭包函数的一种应用,是指在不改变原函数的情况下为原函数添加新的功能的一个函数.它把被装饰的函数作为外层函数的参数传入装饰器,通过闭包操作后返回一个替代版函数. 遵循 ...
- Ubuntu16.04之安装Nutch
1.下载Nutch wget http://mirrors.shu.edu.cn/apache/nutch/2.3.1/apache-nutch-2.3.1-src.zip 2.解压 unzip ap ...