highcharts应用:highcharts历史数据曲线,用jquery实现翻页功能~~

Highcharts曲线实现简单的翻页功能~~

每页显示60个数据,功能基本实现 

$(document).ready(function() {  
  MyCharts();
  $(".dangqianPage").val(1);  
  $("#xia").click(function(){//下一页
  if(i1+60<a.length-1){
       i1=i1+60;       
       $(".dangqianPage").val((i1/60)+1);
       $("p").val((i1/60)+1);
       MyCharts();
      }else{
        alert("这尾页!");
      }
  });
  $("#shang").click(function(){//上一页
  if(i1>=1){
       i1=i1-60;
       MyCharts();       
       $(".dangqianPage").val((i1/60)+1);
       $("p").val((i1/60)+1);
      }else{
        alert("这是首页!");
      }
  });
  $("#first").click(function(){  
       i1=0;
       MyCharts();      
       $(".dangqianPage").val((i1/60)+1);
       $("p").val((i1/60)+1);
  });
  $("#last").click(function(){  
       i1=a.length-(a.length%60);
       MyCharts();       
       $(".dangqianPage").val((i1/60)+1);
       $("p").val((i1/60)+1);
  });
  $("#jump").click(function(){      
       var jump = $(".jumpPage").attr("value");
       i1=(jump-1)*60
       MyCharts();       
       $(".dangqianPage").val((i1/60)+1);
       var replace = (i1/60)+1;         
  });  
  $("#button1").click(function(){
  });   
 }); 
 function MyCharts(){     //high曲线
  chart = new Highcharts.Chart({
   chart: {
    renderTo: 'container',
    defaultSeriesType: 'spline',
    marginRight: 10,
    zoomType: 'x',
     events: {
     
     load: function() {
      var series = this.series[0];
     }
    }
   },
   title: {
    text: '历史数据曲线'
   },
   xAxis: {
    type: 'datetime',
    tickPixelInterval: 100,
    dateTimeLabelFormats:  
                     {  
                      minute: '%e. %b %H:%M',  
                      hour: '%b/%e %H:%M',  
                      day: '%e日/%b',  
                      week: '%e. %b',  
                      month: '%b %y',  
                      year: '%Y' 
                      }       
   },
   yAxis: {
    title: {
     text: 'Value'
    },
    plotLines: [{
     value: 0,
     width: 1,
     color: '#808080'
    }]
   },
   tooltip: {
    formatter: function() {
                  return '<b>'+ this.series.name +'</b><br/>'+
      Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+ 
      Highcharts.numberFormat(this.y, 2);
    }
   },
   plotOptions: {   
        enabled: true   
   }, 
   legend: {
    enabled: false
   },
   exporting: {
    enabled: false
   },   
   series: [{
    name: showtype,
    data: (function() {
     var data = [],
      time = (new Date()).getTime(),
      i;
                    
     for (i = i1; i <i1+61&&i<a.length; i++) {
                       
      data.push({
      //载入数据
          x: t2[i],
       y: a[i]          
      });
     }
     return data;
    })()
   }]
  }); 
  chart = null;  
 }
然后再html中加入对应的按钮~~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值