一.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. 洛谷模拟NOIP考试反思

    洛谷模拟NOIP考试反思 想法 考了这么简单的试qwq然而依然emmmmmm成绩不好 虽然本次难度应该是大于正常PJ难度的但还是很不理想,离预估分数差很多qwq 于是就有了本反思嘤嘤嘤 比赛链接 原比 ...

  2. ubuntu集群下ssh配置总结

    最重要的前提就是:集群中的所有机器的用户名和用户组必须一样 一般做法都是在每台机器上新建用户组和用户名. 比如:sudo addgroup sparks 新建用户组sparks: sudo addus ...

  3. jquery中prop()和attr()用法

    jquery1.6中新加了一个方法prop(),一直没用过它,官方解释只有一句话:获取在匹配的元素集中的第一个元素的属性值. 大家都知道有的浏览器只要写disabled,checked就可以了,而有的 ...

  4. 【HNOI2016】最小公倍数

    [HNOI2016]最小公倍数 容易想到先将所有边按\(a\)排序,然后处理\(b\).(然后我就不会了 我们按\(a\)的权值分块,处理\(a\)权值位于第\(k\)个块的询问的时候,我们先将询问按 ...

  5. 一款国内好用的Linux发行版?Deepin(深度)Linux

    一款国内好用的Linux发行版?Deepin(深度)Linux 目前来说,要将Linux作为桌面解决方案,对于大多数PC用户来说,当然是不现实的,毕竟Linux的主力用户群体依然是少数极客用户.说白了 ...

  6. [MCM] K-mean聚类与DBSCAN聚类 Python

    import matplotlib.pyplot as plt X=[56.70466067,56.70466067,56.70466067,56.70466067,56.70466067,58.03 ...

  7. linux7 安装rac 执行root脚本时候报错

    运行root.sh脚本的时候报错 报错信息: [root@rac1 ~]# /u01/app/oraInventory/orainstRoot.sh Changing permissions of / ...

  8. Spring Security(八):2.4.3 Project Modules

    In Spring Security 3.0, the codebase has been sub-divided into separate jars which more clearly sepa ...

  9. 初学Python——文件操作第三篇

    一.引言 什么?有了第二篇文件操作还不够?远远不够!而且在读完第三篇文件操作还是不够.关于文件的操作,后续的学习中将不断学习新的操作方式,使用更加合适的方法. 进入正题,上一篇讲到,Python对文件 ...

  10. 工具 docker

    环境配置 软件+环境 虚拟机 资源占用 容器  进程隔离 image(镜像)文件 容器文件 docker hub:仓库 docker container run image_name 挂载: 参考链接 ...