一.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. 使用netstat命名排查网络问题的参考指引

    原文链接:http://www.lookdaima.com/WebForms/WebPages/Blanks/Pm/Docs/DocItemDetail.aspx?id=69b487d0-8bf4-4 ...

  2. 虚拟机备份,部署VDP

    VDP是一个基于磁盘的备份和恢复解决方案,可靠且易于部署.VDP这一经过更新的备份设备完全取代了VMware原有的备份架构.而且VDP与VMware vCenter Server 完全集成,可以对备份 ...

  3. Echarts的一些总结

    Echarts是专注做统计图表的插件,其本质是使用canvas进行图表的绘制.而如今它的属性和配置也是越来越丰富.基本的配置很简单,比如饼状图,就是数据和要显示的文字和颜色,柱状图,就是横纵坐标和数据 ...

  4. Error response from daemon:###unable to delete ### (must be forced) - image is being used by stopped

    具体错误:Error response from daemon: conflict: unable to delete f2e2f7b8308b (must be forced) - image is ...

  5. WPF自定义控件(二)の重写原生控件样式模板

    话外篇: 要写一个圆形控件,用Clip,重写模板,去除样式引用圆形图片可以有这三种方式. 开发过程中,我们有时候用WPF原生的控件就能实现自己的需求,但是样式.风格并不能满足我们的需求,那么我们该怎么 ...

  6. Web开发人员vs网页设计师

    Web开发人员vs网页设计师 我们都遇到过,但实际的区别是什么?如果您是该领域的新手,请阅读详细内容,这些内容比您想象的更重要. 经过几周(或几个月)的规划和准备,进行市场调查,与其他企业家交谈,现在 ...

  7. UVA1347-Tour(动态规划基础)

    Problem UVA1347-Tour Accept: 667  Submit: 3866Time Limit: 3000 mSec Problem Description John Doe, a ...

  8. Vim 去除因为 Unix 和 Windows 换行符不同带来的 ^M 问题

    由于各操作系统对换行符的处理不同, Unix: \n Windows : \r\n Mac : \r 所以有时 Vim 打开的文件会有如下情况: 解决方法为:在 Vim 中执行命令 :%s/\r//g ...

  9. Python 字典一个易犯的错误

    一个易犯的错误,关于 Python 的传值(对于不可变量) 和 传引用(对于可变量),浅拷贝和深拷贝.废话不多说,看例子, 直接改变可变字典值,失败, >>> dic = dict. ...

  10. Edusoho之LAMP环境搭建

    主要参考官方文档Ubuntu16.04+Apache+PHP+MySQL+EduSoho 安装教程LAMP环境按照如下搭建是没有问题的,本地虚拟机试验是完全没有问题的. 1.更新 sudo apt-g ...