ICC-Profile

 view release on metacpan or  search on metacpan

lib/ICC/Javascripts/rgraph/RGraph.waterfall.js  view on Meta::CPAN


                    
                    if (prop['chart.shadow']) {
                        RG.setShadow(this, prop['chart.shadow.color'], prop['chart.shadow.offsetx'], prop['chart.shadow.offsety'], prop['chart.shadow.blur']);
                    } else {
                        RG.noShadow(this);
                    }

                    co.rect(x, ma.floor(y), w, ma.floor(h));

                    this.coords.push([x, y, w, h]);
                    


                    runningTotal += this.data[i];

                co.stroke();
                co.fill();
            }
                
            // Store the total
            this.total = runningTotal;

            if (prop['chart.total']) {

                // This is the height of the final bar
                h = this.getYCoord(0) - this.getYCoord(ma.abs(runningTotal));

                /**
                * Set the Y (ie the start point) value
                */
                if (prop['chart.xaxispos'] == 'center') {
                    y = runningTotal > 0 ? this.getYCoord(0) - h : this.getYCoord(0);
                } else {
                    if (runningTotal > 0) {
                        y = this.getYCoord(0) - h;
                    } else {
                        y = this.getYCoord(0);
                    }
                }
            
                // This is the X position of the final bar
                x = x + (prop['chart.hmargin'] * 2) + w;
            
            
                // Final color
                co.fillStyle = prop['chart.colors'][2];
                
                // Allow for sequential colors
                if (prop['chart.colors.sequential']) {
                    co.fillStyle = prop['chart.colors'][seq]
                }
            
                pa2(co, 'b r % % % % s % f %',
                    x, y, w, h,
                    co.strokeStyle,
                    co.fillStyle
                );

                // This is set so that the next iteration of the loop will be able to
                // access THIS iterations coordinates
                var previousCoords = [x, y, w, ma.abs(h)];

                // Add the coordinates to the coords array (the previousCooords array, at
                // this point, is actually THIS iterations coords 
                this.coords.push(previousCoords);
            }





            // Turn off the shadow
            RG.noShadow(this);






            /**
            * This draws the connecting lines
            */
            co.lineWidth   = 1;
            co.strokeStyle = '#666';
            
            co.beginPath();

            for (var i=1,len=this.coords.length; i<len; i+=1) {

                var prev     = this.coords[i - 1],
                    curr     = this.coords[i],
                    prevData = this.data[i-1]
                
                // CANNOT be a part of the var chain above
                var y = (prevData > 0 ? prev[1] : prev[1] + prev[3]);


                co.moveTo(prev[0] + prev[2], y);
                co.lineTo(curr[0],(prevData > 0 ? prev[1] : prev[1] + prev[3]));

            }
            
            co.stroke();
        };




        /**
        * Not used by the class during creating the graph, but is used by event handlers
        * to get the coordinates (if any) of the selected bar
        * 
        * @param object e The event object
        */
        this.getShape =
        this.getBar = function (e)
        {
            /**
            * Loop through the bars determining if the mouse is over a bar
            */
            for (var i=0,len=this.coords.length; i<len; i++) {
    
                var mouseXY = RG.getMouseXY(e),
                    mouseX  = mouseXY[0],



( run in 0.433 second using v1.01-cache-2.11-cpan-71847e10f99 )