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

Rickshaw.Graph.Axis.Rickshaw.Class.create( {

    
initialize: function(args) {

        
this.graph args.graph;
        
this.orientation args.orientation || 'right';

        
this.pixelsPerTick args.pixelsPerTick || 75;
        if (
args.ticksthis.staticTicks args.ticks;
        if (
args.tickValuesthis.tickValues args.tickValues;

        
this.tickSize args.tickSize || 4;
        
this.ticksTreatment args.ticksTreatment || 'plain';

        
this.tickFormat args.tickFormat || function(y) { return };

        
this.berthRate 0.10;

        if (
args.element) {

            
this.element args.element;
            
this.vis d3.select(args.element)
                .
append("svg:svg")
                .
attr('class''rickshaw_graph y_axis');

            
this.element this.vis[0][0];
            
this.element.style.position 'relative';

            
this.setSize({ widthargs.widthheightargs.height });

        } else {
            
this.vis this.graph.vis;
        }

        var 
self this;
        
this.graph.onUpdate( function() { self.render() } );
    },

    
setSize: function(args) {

        
args args || {};

        if (!
this.element) return;

        if (
typeof window !== 'undefined') {

            var 
style window.getComputedStyle(this.element.parentNodenull);
            var 
elementWidth parseInt(style.getPropertyValue('width'), 10);

            if (!
args.auto) {
                var 
elementHeight parseInt(style.getPropertyValue('height'), 10);
            }
        }

        
this.width args.width || elementWidth || this.graph.width this.berthRate;
        
this.height args.height || elementHeight || this.graph.height;

        
this.vis
            
.attr('width'this.width)
            .
attr('height'this.height * (this.berthRate));

        var 
berth this.height this.berthRate;

        if (
this.orientation == 'left') {
            
this.element.style.top = -berth 'px';
        }
    },

    
render: function() {

        if (
this.graph.height !== this._renderHeightthis.setSize({ autotrue });

        
this.ticks this.staticTicks || Math.floor(this.graph.height this.pixelsPerTick);

        var 
axis this._drawAxis(this.graph.y);

        
this._drawGrid(axis);

        
this._renderHeight this.graph.height;
    },

    
_drawAxis: function(scale) {
        var 
axis d3.svg.axis().scale(scale).orient(this.orientation);
        
axis.tickFormat(this.tickFormat);
        if (
this.tickValuesaxis.tickValues(this.tickValues);

        if (
this.orientation == 'left') {
            var 
berth this.height this.berthRate;
            var 
transform 'translate(' this.width ', ' berth ')';
        }

        if (
this.element) {
            
this.vis.selectAll('*').remove();
        }

        
this.vis
            
.append("svg:g")
            .
attr("class", ["y_ticks"this.ticksTreatment].join(" "))
            .
attr("transform"transform)
            .
call(axis.ticks(this.ticks).tickSubdivide(0).tickSize(this.tickSize));

        return 
axis;
    },

    
_drawGrid: function(axis) {
        var 
gridSize = (this.orientation == 'right' : -1) * this.graph.width;

        
this.graph.vis
            
.append("svg:g")
            .
attr("class""y_grid")
            .
call(axis.ticks(this.ticks).tickSubdivide(0).tickSize(gridSize));
    }
} );
?>
Онлайн: 2
Реклама