Chris Leonello avatar Chris Leonello committed a13ca08

partial merit order functionality working.

Comments (0)

Files changed (2)

src/plugins/jqplot.meritOrderAxisRenderer.js

         // first time an axis is called have to
         // for y axes, scale always go from 0 to 1 (0 to 100%)
         if (this.name == 'yaxis' || this.name == 'y2axis') {
-            db.max = 100;
+            db.max = 1;
             this.tickMode = 'even';
             for (var i=0; i<this._series.length; i++) {
                 this._maxSeriesY = Math.max(this._maxSeriesY, this._series[i]._sumy);
                 db.max += this._series[i]._sumx;
             }
         }
-        else if (this.name == 'x2axis'){
-            this.tickMode = (this.tickMode == null) ? 'even' : this.tickMode;
-            for (var i=0; i<this._series.length; i++) {
-                db.max += this._series[i]._sumx;
-            }
-        }
     };
     
     // called with scope of axis
             // yaxis divide ticks in nice intervals from 0 to 1.
             if (this.name == 'yaxis' || this.name == 'y2axis') { 
                 this.min = 0;
-                this.max = 100; 
+                this.max = 1; 
                 // user didn't specify number of ticks.
                 if (!this.numberTicks){
                     if (this.tickInterval) {
             
             // for x axes, have number ot ticks equal to number of series and ticks placed
             // at sum of y values for each series.
-            else if (this.tickMode == 'bar') {
+            else {
                 this.min = 0;
+                this.max = db.max;
+                this.showTicks = false;
                 this.numberTicks = this._series.length + 1;
                 t = new this.tickRenderer(this.tickOptions);
                 if (!this.showTicks) {
                     t.showLabel = false;
                     t.showMark = false;
                 }
-                else if (!this.showTickMarks) {
-                    t.showMark = false;
-                }
-                t.setTick(0, this.name);
-                this._ticks.push(t);
-                
-                temp = 0;
-
-                for (i=1; i<this.numberTicks; i++){
-                    temp += this._series[i-1]._sumy;
-                    t = new this.tickRenderer(this.tickOptions);
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(temp, this.name);
-                    this._ticks.push(t);
-                }
-                this.max = this.max || temp;
-                
-                // if user specified a max and it is greater than sum, add a tick
-                if (this.max > temp) {
-                     t = new this.tickRenderer(this.tickOptions);
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(this.max, this.name);
-                    this._ticks.push(t);
-                    
-                }
-            }
-            
-            else if (this.tickMode == 'even') {
-                this.min = 0;
-                this.max = this.max || db.max;
-                // get a desired number of ticks
-                var nt = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing);
-                range = this.max - this.min;
-                this.numberTicks = nt;
-                this.tickInterval = range / (this.numberTicks - 1);
-
-                for (i=0; i<this.numberTicks; i++){
-                    tt = this.min + i * this.tickInterval;
-                    t = new this.tickRenderer(this.tickOptions);
-                    // var t = new $.jqplot.AxisTickRenderer(this.tickOptions);
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
-                    t.setTick(tt, this.name);
-                    this._ticks.push(t);
-                }
-                
             }
         }
     };

src/plugins/jqplot.meritOrderRenderer.js

     $.jqplot.MeritOrderRenderer.prototype.init = function(options, plot) {
         this.fill = false;
         this.fillRect = true;
-        this.strokeRect = true;
+        this.strokeRect = false;
         this.shadow = false;
         // width of bar on x axis.
         this._xwidth = 0;
         this.renderer.shapeRenderer.init(opts);
         plot.axes.x2axis._series.push(this);
         this._type = 'meritOrder';
-
-        plot.postInitHooks.addOnce(postInit);
     };
     
     // Method: setGridData
         var data = this._plotData;
         this.gridData = [];
         // figure out width on x axis.
-        this._xwidth = xp(this._sumx) - xp(this._xstart);
-        data = [[this._xstart, this.data[0][1]/this._yaxis._maxSeriesY]];
-        this._yhieght = yp(data[0][1]);
+        this._xwidth = xp(this._sumx);
+        this._plotData = [[this._xstart, this.data[0][1]/this._yaxis._maxSeriesY]];
+        this._yheight = yp(0) - yp(this._plotData[0][1]);
 
-        this.gridData.push(xp(data[0][0]), yp(data[0][1]), this._xwidth, this._yheight);
+        this.gridData.push([xp(this._plotData[0][0]), yp(this._plotData[0][1]), this._xwidth, this._yheight]);
     };
     
     // Method: makeGridData
         // since we have to know about data of previous series
         // It doesn't really make any sense to use arbitrary
         // data for this type of plot.
-        var xp = this._xaxis.series_u2p;
-        var yp = this._yaxis.series_u2p;
-        data = this._plotData;
-        gd = [];
-        // figure out width on x axis.
-        this._xwidth = xp(this._sumx) - xp(this._xstart);
-        data = [[this._xstart, this.data[0][1]/this._yaxis._maxSeriesY]];
-        this._yhieght = yp(data[0][1]);
+        // var xp = this._xaxis.series_u2p;
+        // var yp = this._yaxis.series_u2p;
+        // data = this._plotData;
+        // gd = [];
+        // // figure out width on x axis.
+        // this._xwidth = xp(this._sumx) - xp(this._xstart);
+        // data = [[this._xstart, this.data[0][1]/this._yaxis._maxSeriesY]];
+        // this._yhieght = yp(data[0][1]);
 
-        gd.push(xp(data[0][0]), yp(data[0][1]), this._xwidth, this._yheight);
+        // gd.push([xp(data[0][0]), yp(data[0][1]), this._xwidth, this._yheight]);
 
-        return gd;
+        // return gd;
+        return this.gridData;
     };
     
 
             options.legend.preDraw = true;
         }
     }
-    
-    $.jqplot.preInitHooks.addOnce(preInit);
 
     // called with scope of a plot.
     function postInit(target, data, options) {
         var ymax = 0;
         for (var i=series.length; i--;) {
             s = series[i];
-            order.unshift([i, s._sumy]);
-            ymax = Math.max(ymax, s._sumy);
+            if (s._type === 'meritOrder') {
+                order.unshift([i, s._sumy]);
+                ymax = Math.max(ymax, s._sumy);
+            }
         }
 
         order.sort(compare);
 
         var xtot = 0;
 
-        for (var i=order.length; i--;) {
+        for (var i=0, l=order.length; i<l; i++) {
             s = series[order[i][0]];
-            s._meritOrder = i;
-            s._xstart = xtot;
-            xtot += s._sumx;
+            if (s._type === 'meritOrder') {
+                s._meritOrder = i;
+                s._xstart = xtot;
+                xtot += s._sumx;
+            }
         }
     }
+    $.jqplot.preInitHooks.push(preInit);
+    $.jqplot.postInitHooks.push(postInit);
     
 })(jQuery);    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.