一.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图片保存的更多相关文章

  1. Java - PhantomJS + EChartsConvert实现ECharts图片保存到服务端

    1.所需工具 1>phantomjs:官网下载http://phantomjs.org/download.html 国内镜像http://npm.taobao.org/dist/phantomj ...

  2. ECharts外部调用保存为图片操作及工作流接线mouseenter和mouseleave由于鼠标移动速度过快导致问题解决办法

    记录两个项目开发中遇到的问题,一个是ECharts外部调用保存为图片操作,一个是workflow工作流连接曲线onmouseenter和onmouseleave事件由于鼠标移动过快触发问题. 一.外部 ...

  3. php 获取远程图片保存到本地

    php 获取远程图片保存到本地 使用两个函数 1.获取远程文件 2.把图片保存到本地 /** * 获取远程图片并把它保存到本地 * $url 是远程图片的完整URL地址,不能为空. */ functi ...

  4. 用qt代码怎样编写图片保存格式[qt4.6]

    用qt代码怎样编写图片保存格式 qt提供了多个保存图片的接口,比较常用的接口如下 bool QPixmap::save ( const QString & fileName, const ch ...

  5. iOS 将图片保存到本地

    //将图片保存到本地 + (void)SaveImageToLocal:(UIImage*)image Keys:(NSString*)key {     NSUserDefaults* prefer ...

  6. C# 图片保存到数据库和从数据库读取图片并显示

    图片保存到数据库的方法: public void imgToDB(string sql)        {   //参数sql中要求保存的imge变量名称为@images            //调 ...

  7. file_put_contents() 图片保存 函数成功之后返回值

    今天弄图片保存时,用到file_put_contents()来保存图片,运行了几次,发下一直没有数据出来,以为是这个函数没操作成功 于是查看了下这个函数的用法和返回值,发现我输出的返回都正确,后来才发 ...

  8. iOS9中将图片保存到照片中的某个相册的方法说明

    iOS9中将图片保存到照片中的某个相册的方法说明 在App中很经常遇到的就是用户点击某张图片后将图片保存到本地,下面介绍下iOS中保存图片的一些东西 1.首先,在iOS中把图片保存到系统照片是比较简单 ...

  9. 24位和8位BMP图片保存纯C代码

    BMP图片大家都知道,可以通过查看BMP图片结构使用纯C就可以打开,编辑,处理,保存图片.非常方便使用. 具体BMP结构可以参考:wingdi.h头文件.今天主要在进行删减代码,需要把多余的代码删除, ...

随机推荐

  1. IPerf——网络测试工具介绍与源码解析(5)

    本篇随笔讲述一下TCP协议下,双向测试模式和交易测试模式下客户端和服务端执行的情况: 双向测试模式: 官方文档的解释 Run Iperf in dual testing mode. This will ...

  2. AI学习---分类算法[K-近邻 + 朴素贝叶斯 + 决策树 + 随机森林 ]

    分类算法:对目标值进行分类的算法    1.sklearn转换器(特征工程)和预估器(机器学习)    2.KNN算法(根据邻居确定类别 + 欧氏距离 + k的确定),时间复杂度高,适合小数据    ...

  3. Hexo使用细节及各种问题

    解决markdown图片不显示(返回403 forbidden).添加本地图片无法显示.修改文章page模板.同时部署发布同步到多个仓库站点(Github.coding.gitee 码云) 图片不显示 ...

  4. C# -- 使用递归列出文件夹目录及目录下的文件

    使用递归列出文件夹目录及目录的下文件 1.使用递归列出文件夹目录及目录下文件,并将文件目录结构在TreeView控件中显示出来. 新建一个WinForm应用程序,放置一个TreeView控件: 代码实 ...

  5. 力扣算法题—050计算pow(x, n)

    #include "000库函数.h" //使用折半算法 牛逼算法 class Solution { public: double myPow(double x, int n) { ...

  6. 【Linux基础】tr命令替换和删除字符

    1.tr命令 tr可以对来自标准输入的字符进行替换.压缩和删除,可以将一组字符变成另外一组字符.通过使用 tr,您可以非常容易地实现 sed 的许多最基本功能.您可以将 tr 看作为 sed 的(极其 ...

  7. CF 1110 D/E

    CF 1110 D. Jongmah 题目大意:给你​\(n\)个瓷砖,每块瓷砖上有一个数字​\(a_i,(1\leq a_i\leq m)\).你可以将三个有连续数字​\((比如3,4,5)\)的瓷 ...

  8. Centos 6.7 安装mongodb

    下载mongodb  https://www.mongodb.com/download-center#community 2.解压文件 tar -zxvf mongodb-linux-x86_64-3 ...

  9. ZooKeeper典型应用场景概览

    ZooKeeper是一个高可用的分布式数据管理与系统协调框架.基于对Paxos算法的实现,使该框架保证了分布式环境中数据的强一致性,也正是基于这样的特性,使得ZooKeeper解决很多分布式问题.网上 ...

  10. vmware panic(CPU 0 caller 0x)launchd exited

    编辑VMX文件,在最后添加一行(g4560测试通过):cpuid.1.eax = "00000000000000010000011010100101"