Вход Регистрация
Файл: templates/backend/default/assets/plugins/jquery-ricksaw-chart/js/Rickshaw.Series.FixedDuration.js
Строк: 91
<?php
Rickshaw
.namespace('Rickshaw.Series.FixedDuration');

Rickshaw.Series.FixedDuration Rickshaw.Class.create(Rickshaw.Series, {

    
initialize: function (datapaletteoptions) {

        
options options || {};

        if (
typeof(options.timeInterval) === 'undefined') {
            throw new 
Error('FixedDuration series requires timeInterval');
        }

        if (
typeof(options.maxDataPoints) === 'undefined') {
            throw new 
Error('FixedDuration series requires maxDataPoints');
        }

        
this.palette = new Rickshaw.Color.Palette(palette);
        
this.timeBase typeof(options.timeBase) === 'undefined' Math.floor(new Date().getTime() / 1000) : options.timeBase;
        
this.setTimeInterval(options.timeInterval);

        if (
this[0] && this[0].data && this[0].data.length) {
            
this.currentSize this[0].data.length;
            
this.currentIndex this[0].data.length;
        } else {
            
this.currentSize  0;
            
this.currentIndex 0;
        }

        
this.maxDataPoints options.maxDataPoints;


        if (
data && (typeof(data) == "object") && Array.isArray(data)) {
            
data.forEach( function (item) { this.addItem(item) }, this );
            
this.currentSize  += 1;
            
this.currentIndex += 1;
        }

        
// reset timeBase for zero-filled values if needed
        
this.timeBase -= (this.maxDataPoints this.currentSize) * this.timeInterval;

        
// zero-fill up to maxDataPoints size if we don't have that much data yet
        
if ((typeof(this.maxDataPoints) !== 'undefined') && (this.currentSize this.maxDataPoints)) {
            for (var 
this.maxDataPoints this.currentSize 11i--) {
                
this.currentSize  += 1;
                
this.currentIndex += 1;
                
this.forEach( function (item) {
                    
item.data.unshift({ x: ((i-1) * this.timeInterval || 1) + this.timeBasey0i});
                }, 
this );
            }
        }
    },

    
addData: function($superdatax) {

        
$super(datax);

        
this.currentSize += 1;
        
this.currentIndex += 1;

        if (
this.maxDataPoints !== undefined) {
            while (
this.currentSize this.maxDataPoints) {
                
this.dropData();
            }
        }
    },

    
dropData: function() {

        
this.forEach(function(item) {
            
item.data.splice(01);
        } );

        
this.currentSize -= 1;
    },

    
getIndex: function () {
        return 
this.currentIndex;
    }
} );
?>
Онлайн: 1
Реклама