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

Rickshaw.Graph.Renderer Rickshaw.Class.create( {

    
initialize: function(args) {
        
this.graph args.graph;
        
this.tension args.tension || this.tension;
        
this.graph.unstacker this.graph.unstacker || new Rickshaw.Graph.Unstacker( { graphthis.graph } );
        
this.configure(args);
    },

    
seriesPathFactory: function() {
        
//implement in subclass
    
},

    
seriesStrokeFactory: function() {
        
// implement in subclass
    
},

    
defaults: function() {
        return {
            
tension0.8,
            
strokeWidth2,
            
unstacktrue,
            
padding: { top0.01right0bottom0.01left},
            
strokefalse,
            
fillfalse
        
};
    },

    
domain: function(data) {

        var 
stackedData data || this.graph.stackedData || this.graph.stackData();
        var 
firstPoint stackedData[0][0];

        if (
firstPoint === undefined) {
            return { 
x: [nullnull], y: [nullnull] };
        }

        var 
xMin firstPoint.x;
        var 
xMax firstPoint.x;

        var 
yMin firstPoint.firstPoint.y0;
        var 
yMax firstPoint.firstPoint.y0;

        
stackedData.forEach( function(series) {

            
series.forEach( function(d) {

                if (
d.== null) return;

                var 
d.d.y0;

                if (
yMinyMin y;
                if (
yMaxyMax y;
            } );

            if (
series[0].xMinxMin series[0].x;
            if (
series[series.length 1].xMaxxMax series[series.length 1].x;
        } );

        
xMin -= (xMax xMin) * this.padding.left;
        
xMax += (xMax xMin) * this.padding.right;

        
yMin this.graph.min === 'auto' yMin this.graph.min || 0;
        
yMax this.graph.max === undefined yMax this.graph.max;

        if (
this.graph.min === 'auto' || yMin 0) {
            
yMin -= (yMax yMin) * this.padding.bottom;
        }

        if (
this.graph.max === undefined) {
            
yMax += (yMax yMin) * this.padding.top;
        }

        return { 
x: [xMinxMax], y: [yMinyMax] };
    },

    
render: function(args) {

        
args args || {};

        var 
graph this.graph;
        var 
series args.series || graph.series;

        var 
vis args.vis || graph.vis;
        
vis.selectAll('*').remove();

        var 
data series
            
.filter(function(s) { return !s.disabled })
            .
map(function(s) { return s.stack });

        var 
nodes vis.selectAll("path")
            .
data(data)
            .
enter().append("svg:path")
            .
attr("d"this.seriesPathFactory());

        var 
0;
        
series.forEach( function(series) {
            if (
series.disabled) return;
            
series.path nodes[0][i++];
            
this._styleSeries(series);
        }, 
this );
    },

    
_styleSeries: function(series) {

        var 
fill this.fill series.color 'none';
        var 
stroke this.stroke series.color 'none';

        
series.path.setAttribute('fill'fill);
        
series.path.setAttribute('stroke'stroke);
        
series.path.setAttribute('stroke-width'this.strokeWidth);
        
series.path.setAttribute('class'series.className);
    },

    
configure: function(args) {

        
args args || {};

        
Rickshaw.keys(this.defaults()).forEach( function(key) {

            if (!
args.hasOwnProperty(key)) {
                
this[key] = this[key] || this.graph[key] || this.defaults()[key];
                return;
            }

            if (
typeof this.defaults()[key] == 'object') {

                
Rickshaw.keys(this.defaults()[key]).forEach( function(k) {

                    
this[key][k] =
                        
args[key][k] !== undefined args[key][k] :
                        
this[key][k] !== undefined this[key][k] :
                        
this.defaults()[key][k];
                }, 
this );

            } else {
                
this[key] =
                    
args[key] !== undefined args[key] :
                    
this[key] !== undefined this[key] :
                    
this.graph[key] !== undefined this.graph[key] :
                    
this.defaults()[key];
            }

        }, 
this );
    },

    
setStrokeWidth: function(strokeWidth) {
        if (
strokeWidth !== undefined) {
            
this.strokeWidth strokeWidth;
        }
    },

    
setTension: function(tension) {
        if (
tension !== undefined) {
            
this.tension tension;
        }
    }
} );
?>
Онлайн: 0
Реклама