43ECharts:心电图效果

Stella981
• 阅读 897
一、心电图效果之单线条
```html:run
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Echarts实现心电图效果</title>
    <script src="https://cdn.bootcss.com/echarts/3.7.1/echarts.js"></script>
</head>
<body>
<div id="totalFlowRate" style="height:300px;"></div>
</body>
</html>
<script type="text/javascript">
    var totalFlowRate = echarts.init(document.getElementById('totalFlowRate'));
    var xAxisData=[];
    var yAxisData=[];
    for(var i=500 ;i>0;i--){
        xAxisData.push(i+"秒前");
    }
    for(i=1;i<501;i++){
        yAxisData.push(Math.round(Math.random()*1000));
    }
    var totalFlowRateOption = {
        animation:false,
        title: {
            text: '总流量(kbps)'/*,
             left:"110px"*/
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross'
            }
        },
        grid: {
            left: 50/*"50px"*/,
            right: 15/*"15px"*/
        },
        legend: {
            data:['当前流量']
        },
        xAxis: {
            boundaryGap: false,
            data: xAxisData
        },
        yAxis: {
            boundaryGap:false
        },
        series: {
            symbol:"none",/*去掉小圆点*/
            name: '当前流量',
            type: 'line',
            itemStyle : {
                normal : {
                    lineStyle:{
                        width:2,//折线宽度
                        color:"#FF0000"//折线颜色
                    }
                }
            },
            data: yAxisData/*,
             smooth:true//0-1之间的数字或true或false,显示为平滑的曲线*/
        }
    };
    totalFlowRate.setOption(totalFlowRateOption);
    setInterval(function(){
        yAxisData.push(Math.round(Math.random()*1000));
        yAxisData.shift();
        totalFlowRate.setOption(totalFlowRateOption);
    },100);
    /*setInterval(function(){
        yAxisData.push(Math.round(Math.random()*1000));
        yAxisData.shift();
        var myselfOption = totalFlowRate.getOption();
        myselfOption.series[0].data=yAxisData;
        totalFlowRate.setOption(myselfOption);
    },100);*/
</script>
```
二、心电图效果之单线条下有阴影
```html:run
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Echarts实现心电图效果</title>
    <script src="https://cdn.bootcss.com/echarts/3.7.1/echarts.js"></script>
</head>
<body>
<div id="totalFlowRate" style="height:300px;"></div>
</body>
</html>
<script type="text/javascript">
    var totalFlowRate = echarts.init(document.getElementById('totalFlowRate'));
    var xAxisData=[];
    var yAxisData=[];
    for(var i=100 ;i>0;i--){
        xAxisData.push(i+"秒前");
    }
    for(i=1;i<101;i++){
        yAxisData.push(Math.round(Math.random()*1000));
    }
    setInterval(function(){
        yAxisData.push(Math.round(Math.random()*1000));
        yAxisData.shift();
        var totalFlowRateOption = {
            animation:false,
            title: {
                text: '总流量(kbps)'/*,
                 left:"110px"*/
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross'
                }
            },
            grid: {
                left: 50/*"50px"*/,
                right: 15/*"15px"*/
            },
            legend: {
                data:['当前流量'],
                textStyle:{color:"#66b3ff"}/*图例(legend)说明文字的颜色*/
            },
            xAxis: {
                boundaryGap: false,
                data: xAxisData,
                splitLine:{show: true}/*网格线*/
            },
            yAxis: {
                boundaryGap:false,
                splitLine:{show: true}/*网格线*/
            },
            series: {
              /*itemStyle: {normal: {areaStyle: {type: 'default'}}},*/
              itemStyle : {
                normal : {
                  lineStyle:{
                    color:'#92c2ff'/*折线的颜色*/
                  },
                  color:"#66b3ff"/*图例(legend)的颜色,不是图例说明文字的颜色*/
                }
              },
              areaStyle: {normal: {
                color: new echarts.graphic.LinearGradient(
                /* 声明渐变色,传入5个参数。
                前4个参数用于配置渐变色的起止位置, 这4个参数依次对应右/下/左/上四个方位。
                其中0 0 0 1则代表渐变色从正上方开始。
                第5个参数则是一个数组, 用于配置颜色的渐变过程,包含起止位置和起止颜色 */
                  0, 0, 0, 1,
                  [
                    {offset: 0, color: '#66b3ff'},
                   /* {offset: 0.5, color: '#c4e1ff'},*/
                    {offset: 1, color: '#ecf5ff'}
                  ]
                )
              }},
              symbol:"none",/*去掉小圆点*/
              name: '当前流量',
              type: 'line',
              data: yAxisData/*,
               smooth:true//显示为平滑的曲线*/
            }
        };
        totalFlowRate.setOption(totalFlowRateOption);
    },100);
</script>
```
三、鼠标移入移出变背景色
```html:run
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Echarts实现心电图效果</title>
    <script src="https://cdn.bootcss.com/echarts/3.7.1/echarts.js"></script>
</head>
<body>
<div id="totalFlowRate" style="height:300px;"></div>
</body>
</html>
<script type="text/javascript">
    var totalFlowRate = echarts.init(document.getElementById('totalFlowRate'));
    var xAxisData=[];
    var yAxisData=[];
    for(var i=100 ;i>0;i--){
        xAxisData.push(i+"秒前");
    }
    for(i=1;i<101;i++){
        yAxisData.push(Math.round(Math.random()*1000));
    }

    yAxisData.push(Math.round(Math.random()*1000));
    yAxisData.shift();
    var totalFlowRateOption = {
      backgroundColor: '#ffffff',
      animation:false,
      title: {
          text: '总流量(kbps)'/*,
          left:"110px"*/
      },
      tooltip: {
          trigger: 'axis',
          axisPointer: {
              type: 'cross'
          }
      },
      grid: {
          left: 50/*"50px"*/,
          right: 15/*"15px"*/
      },
      legend: {
          data:['当前流量'],
          textStyle:{color:"#66b3ff"}/*图例(legend)说明文字的颜色*/
      },
      xAxis: {
          boundaryGap: false,
          data: xAxisData,
          splitLine:{show: true}/*网格线*/
      },
      yAxis: {
          boundaryGap:false,
          splitLine:{show: true}/*网格线*/
      },
      series: {
        /*itemStyle: {normal: {areaStyle: {type: 'default'}}},*/
        itemStyle : {
          normal : {
            lineStyle:{
              color:'#92c2ff'/*折线的颜色*/
            },
            color:"#66b3ff"/*图例(legend)的颜色,不是图例说明文字的颜色*/
          }
        },
        areaStyle: {normal: {
          color: new echarts.graphic.LinearGradient(
            0, 0, 0, 1,
            [
              {offset: 0, color: '#66b3ff'},
            /* {offset: 0.5, color: '#c4e1ff'},*/
              {offset: 1, color: '#ecf5ff'}
            ]
          )
        }},
        symbol:"none",/*去掉小圆点*/
        name: '当前流量',
        type: 'line',
        data: yAxisData/*,
        smooth:true//显示为平滑的曲线*/
      }
    };
  totalFlowRate.setOption(totalFlowRateOption);
  totalFlowRate.getZr().on('mousemove', function (params) {
    var pointInPixel = [params.offsetX, params.offsetY];
    if (totalFlowRate.containPixel('grid', pointInPixel)) {  
      totalFlowRateOption.backgroundColor = '#F6F8FC';
      totalFlowRate.setOption(totalFlowRateOption);
    }
  });
  totalFlowRate.getZr().on('mouseout', function (params) {
    var pointInPixel = [params.offsetX, params.offsetY];
    if (!totalFlowRate.containPixel('grid', pointInPixel)) {
      totalFlowRateOption.backgroundColor = '#ffffff';
      totalFlowRate.setOption(totalFlowRateOption);
    }
  });
    
</script>
```

四、心电图效果之7500条数据同页显示
```html:run
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Echarts实现心电图效果</title>
    <script src="https://cdn.bootcss.com/echarts/3.7.1/echarts.js"></script>
</head>
<body>
<div id="totalFlowRate" style="height:300px;"></div>
</body>
</html>
<script type="text/javascript">
    var totalFlowRate = echarts.init(document.getElementById('totalFlowRate'));
    var xAxisData=[];
    var yAxisData=[];
    for(var i=7500 ;i>0;i--){
        xAxisData.push(i+"秒前");
    }
    for(i=1;i<7501;i++){
        yAxisData.push(Math.round(Math.random()*1000));
    }
    var totalFlowRateOption = {
        animation:false,
        title: {
            text: '总流量(kbps)'/*,
             left:"110px"*/
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross'
            }
        },
        grid: {
            left: 50/*"50px"*/,
            right: 15/*"15px"*/
        },
        legend: {
            data:['当前流量']
        },
        xAxis: {
            boundaryGap: false,
            data: xAxisData
        },
        yAxis: {
            boundaryGap:false
        },
        series: {
            symbol:"none",/*去掉小圆点*/
            name: '当前流量',
            type: 'line',
            data: yAxisData/*,
             smooth:true//显示为平滑的曲线*/
        }
    };
    totalFlowRate.setOption(totalFlowRateOption);
    setInterval(function(){
        yAxisData.push(Math.round(Math.random()*1000));
        yAxisData.shift();
        totalFlowRate.setOption(totalFlowRateOption);
    },100);
    /*setInterval(function(){
     yAxisData.push(Math.round(Math.random()*1000));
     yAxisData.shift();
     var myselfOption = totalFlowRate.getOption();
     myselfOption.series[0].data=yAxisData;
     totalFlowRate.setOption(myselfOption);
     },100);*/
</script>
```
点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
待兔 待兔
5个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Easter79 Easter79
3年前
springboot2.0结合webuploader实现文件分片上传
\toc\1\.上传页面代码<!DOCTYPEhtml<htmllang"en"<head<metacharset"UTF8"<titlewebuploader文件上传</title<!引入CSS
Stella981 Stella981
3年前
JS获取本地ip的方法
<!DOCTYPEhtml<htmllang"en"<head<metacharset"UTF8"<title获取IP地址</title<scriptsrc"http://pv.sohu.com/cityjson?ieutf8"</script
Wesley13 Wesley13
3年前
Java爬虫之JSoup使用教程
title:Java爬虫之JSoup使用教程date:201812248:00:000800update:201812248:00:000800author:mecover:https://imgblog.csdnimg.cn/20181224144920712(https://www.oschin
Wesley13 Wesley13
3年前
HTML5 基础知识(二)
<!DOCTYPEhtml<htmllang"en"<head<metacharset"utf8"/<title</title</head<body</body</html<!DOCTYPEhtml
Stella981 Stella981
3年前
JavaScript设置倒计时效果
<!DOCTYPEhtml<htmllang"en"<head<metacharset"UTF8"<title倒计时效果</title</head<body<formname"myForm"<inputtype"t
Stella981 Stella981
3年前
Highcharts教程
1.html页面写法<!DOCTYPEhtml<htmllang"en"<head<metacharset"UTF8"<title第一个Highcharts图表</title<!引入jquery.js<scrip
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
11个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这