Chris Leonello avatar Chris Leonello committed 2c06f3a

Fixed bug #17 again. Fixed dragable color issue when used with trend lines. Trend lines were being drawn on top of the drag line, which made drag line look to have the same color as the trend line. now dragable disables trend line drawing while dragging.

Also fixed color of marker while dragging.

Comments (0)

Files changed (4)

src/jqplot.lineRenderer.js

         // now draw the markers
         if (this.markerRenderer.show) {
             for (i=0; i<gd.length; i++) {
-                this.markerRenderer.draw(gd[i][0], gd[i][1], ctx, opts);
+                this.markerRenderer.draw(gd[i][0], gd[i][1], ctx, opts.markerOptions);
             }
         }
         

src/jqplot.markerRenderer.js

         this.shapeRenderer.init(shopt);
     };
     
-    $.jqplot.MarkerRenderer.prototype.drawDiamond = function(x, y, ctx, fill) {
+    $.jqplot.MarkerRenderer.prototype.drawDiamond = function(x, y, ctx, fill, options) {
         var stretch = 1.2;
         var dx = this.size/2/stretch;
         var dy = this.size/2*stretch;
         if (this.shadow) {
             this.shadowRenderer.draw(ctx, points);
         }
-        this.shapeRenderer.draw(ctx, points);
+        this.shapeRenderer.draw(ctx, points, options);
 
         ctx.restore();
     };
     
-    $.jqplot.MarkerRenderer.prototype.drawSquare = function(x, y, ctx, fill) {
+    $.jqplot.MarkerRenderer.prototype.drawSquare = function(x, y, ctx, fill, options) {
         var stretch = 1.0;
         var dx = this.size/2/stretch;
         var dy = this.size/2*stretch;
         if (this.shadow) {
             this.shadowRenderer.draw(ctx, points);
         }
-        this.shapeRenderer.draw(ctx, points);
+        this.shapeRenderer.draw(ctx, points, options);
 
         ctx.restore();
     };
     
-    $.jqplot.MarkerRenderer.prototype.drawCircle = function(x, y, ctx, fill) {
+    $.jqplot.MarkerRenderer.prototype.drawCircle = function(x, y, ctx, fill, options) {
         var radius = this.size/2;
         var end = 2*Math.PI;
         var points = [x, y, radius, 0, end, true];
         if (this.shadow) {
             this.shadowRenderer.draw(ctx, points);
         }
-        this.shapeRenderer.draw(ctx, points);
+        this.shapeRenderer.draw(ctx, points, options);
         
         ctx.restore();
     };
     
     $.jqplot.MarkerRenderer.prototype.draw = function(x, y, ctx, options) {
+        options = options || {};
         switch (this.style) {
             case 'diamond':
-                this.drawDiamond(x,y,ctx, false);
+                this.drawDiamond(x,y,ctx, false, options);
                 break;
             case 'filledDiamond':
-                this.drawDiamond(x,y,ctx, true);
+                this.drawDiamond(x,y,ctx, true, options);
                 break;
             case 'circle':
-                this.drawCircle(x,y,ctx, false);
+                this.drawCircle(x,y,ctx, false, options);
                 break;
             case 'filledCircle':
-                this.drawCircle(x,y,ctx, true);
+                this.drawCircle(x,y,ctx, true, options);
                 break;
             case 'square':
-                this.drawSquare(x,y,ctx, false);
+                this.drawSquare(x,y,ctx, false, options);
                 break;
             case 'filledSquare':
-                this.drawSquare(x,y,ctx, true);
+                this.drawSquare(x,y,ctx, true, options);
                 break;
             default:
-                this.drawDiamond(x,y,ctx, false);
+                this.drawDiamond(x,y,ctx, false, options);
                 break;
         }
     };

src/plugins/jqplot.dragable.js

         mr.style = smr.style;
         mr.lineWidth = smr.lineWidth + 2.5;
         mr.size = smr.size + 5;
-        var rgba = $.jqplot.getColorComponents(smr.color);
-        var newrgb = [rgba[0], rgba[1], rgba[2]];
-        var alpha = (rgba[3] >= 0.6) ? rgba[3]*0.6 : rgba[3]*(2-rgba[3]);
-        var color = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+alpha+')';
-        drag.color = color;
-        mr.color = color;
+        if (!drag.color) {
+            var rgba = $.jqplot.getColorComponents(smr.color);
+            var newrgb = [rgba[0], rgba[1], rgba[2]];
+            var alpha = (rgba[3] >= 0.6) ? rgba[3]*0.6 : rgba[3]*(2-rgba[3]);
+            drag.color = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+alpha+')';
+        }
+        mr.color = drag.color;
         mr.init();
 
         var start = (neighbor.pointIndex > 0) ? neighbor.pointIndex - 1 : 0;
 	        else {
 	            drag._gridData[0] = [x, y];
 	        }
-	        plot.series[dp.seriesIndex].draw(dc._ctx, {gridData:drag._gridData, shadow:false, preventJqPlotSeriesDrawTrigger:true, color:drag.color});
+	        plot.series[dp.seriesIndex].draw(dc._ctx, {gridData:drag._gridData, shadow:false, preventJqPlotSeriesDrawTrigger:true, color:drag.color, markerOptions:{color:drag.color, shadow:false}, trendline:{show:false}});
 	        dc._elem.trigger('jqplotSeriesPointChange', [dp.seriesIndex, dp.pointIndex, [xu,yu], [x,y]]);
 	    }
 	    else if (neighbor != null) {

src/plugins/jqplot.trendline.js

     
     // called within scope of series object
     function drawTrendline(sctx, options) {
-        if (this.trendline.show) {
+        // if we have options, merge trendline options in with precedence
+        if (options) {
+            $.extend(true, options, options.trendline);
+        }
+        else {
+            options = {};
+        }
+        if (options.show == null) {
+            options.show = this.trendline.show;
+        }
+        if (options.show) {
             var fit;
             // this.renderer.setGridData.call(this);
             var data = options.data || this.data;
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.