1. Chris Leonello
  2. jqplot

Commits

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.

  • Participants
  • Parent commits aeda880
  • Branches default

Comments (0)

Files changed (4)

File src/jqplot.lineRenderer.js

View file
         // 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);
             }
         }
         

File src/jqplot.markerRenderer.js

View file
         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;
         }
     };

File src/plugins/jqplot.dragable.js

View file
         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) {

File src/plugins/jqplot.trendline.js

View file
     
     // 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;