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头文件.今天主要在进行删减代码,需要把多余的代码删除, ...
随机推荐
- numpy中stack、hstack,vstack,dstack函数功能解释
https://blog.csdn.net/Riverhope/article/details/78922006 https://blog.csdn.net/ygys1234/article/deta ...
- Welcom to Swift
1.第一个程序 import Foundation println(“hello world”) 2.常用数据类型 int/UInt/Double/Float/Bool/String/Array/Di ...
- ECharts图表之柱状折线混合图
Echarts 官网主页 http://echarts.baidu.com/index.html Echarts 更多项目案例 http://echarts.baidu.com/echarts2/ ...
- 15.scrapy中selenium的应用
引入 在通过scrapy框架进行某些网站数据爬取的时候,往往会碰到页面动态数据加载的情况发生,如果直接使用scrapy对其url发请求,是绝对获取不到那部分动态加载出来的数据值.但是通过观察我们会发现 ...
- python 基本模块 random、os、sys
一.random模块 所有关于随机相关的内容都在random模块中 import random print(random.random()) # 0-1⼩数 print(random.uniform( ...
- (转)Spring Boot 2 (三):Spring Boot 开源软件都有哪些?
http://www.ityouknow.com/springboot/2018/03/05/spring-boot-open-source.html 2016年 Spring Boot 还没有被广泛 ...
- centos 防火墙的操作
systemctl start firewalld systemctl restart firewalld systemctl status firewalld systemctl enable fi ...
- Get https://192.168.2.119/v2/: dial tcp 192.168.2.119:443: getsockopt: connection refused
Get https://192.168.2.119/v2/: dial tcp 192.168.2.119:443: getsockopt: connection refused
- day1 计算机组成、操作系统
一:编程与编程的目的 1.什么是语言?什么是编程语言? 语言是一个事物与另一个事物沟通的介质. 编程语言是程序员与计算机沟通的介质. 2.什么是编程?为什么要编程? 编程是程序员将自己想要让计算机做的 ...
- windows下简单的缓冲区溢出
缓冲区溢出是什么? 当缓冲区边界限制不严格时,由于变量传入畸形数据或程序运行错误,导致缓冲区被“撑爆”,从而覆盖了相邻内存区域的数据 成功修改内存数据,可造成进程劫持,执行恶意代码,获取服务器控制权等 ...