Commits

Anonymous committed fa3d058

Trendline appears to be broken. Trying to fix.

  • Participants
  • Parent commits 3ea7d46

Comments (0)

Files changed (5)

File examples/barTest.html

   
     <script type="text/javascript">    
     $(document).ready(function(){
-      $.jqplot.config.enablePlugins = true;
         $('#code').load('barTest.js');
         $('#code').dialog({
 			height: 'auto',

File examples/barTest.js

 $(document).ready(function(){
 
-    $.jqplot.config.enablePlugins = true;
-
     s1 = [2, 6, 7, 10];
     s2 = [7, 5, 3, 2];
     s3 = [14, 9, 3, 8];
         }      
     });
 
-    plot6 = $.jqplot('chart6', [[1,2,3,4]]);
+    plot6 = $.jqplot('chart6', [[1,2,3,4]], {seriesDefaults:{highlighter:{show:true}}});
     
     $('#chart1').bind('jqplotDataClick', 
         function (ev, seriesIndex, pointIndex, data) {

File examples/trendlineDragableCustomization.html

   
   $(document).ready(function(){
       $.jqplot.config.enablePlugins = true;
-    
-    $.jqplot.enablePlugins = false;
 
     s1 = [['23-May-08',1],['24-May-08',4],['25-May-08',2],['26-May-08', 6]];
     s2 = [['23-May-08',2],['24-May-08',3],['25-May-08',7],['26-May-08', 4]];

File src/jqplot.lineRenderer.js

     
     // called with scope of series.
     $.jqplot.LineRenderer.prototype.init = function(options, plot) {
-        // prop: highlightMouseOver
-        // True to highlight slice when moused over.
-        // This must be false to enable highlightMouseDown to highlight when clicking on an area on a filled plot.
-        this.highlightMouseOver = true;
-        // prop: highlightMouseDown
-        // True to highlight when a mouse button is pressed over a area on a filled plot.
-        // This will be disabled if highlightMouseOver is true.
-        this.highlightMouseDown = false;
-        // prop: highlightColor
-        // color to use when highlighting an area on a filled plot.
-        this.highlightColor = null;
-        
-        // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
-        if (options.highlightMouseDown && options.highlightMouseOver == null) {
-            options.highlightMouseOver = false;
-        }
-        
-        $.extend(true, this, {highlightMouseOver: options.highlightMouseOver, highlightMouseDown: options.highlightMouseDown, highlightColor: options.highlightColor});
+        options = options || {};
+        var lopts = {highlightMouseOver: options.highlightMouseOver, highlightMouseDown: options.highlightMouseDown, highlightColor: options.highlightColor};
         
         delete (options.highlightMouseOver);
         delete (options.highlightMouseDown);
         this.renderer.shadowRenderer.init(sopts);
         this._areaPoints = [];
         this._boundingBox = [[0,0],[0,0]];
-        if (!this.highlightColor) {
-            this.highlightColor = $.jqplot.computeHighlightColors(this.fillColor);
+        
+        if (!this.isTrendline && this.fill) {
+        
+            // prop: highlightMouseOver
+            // True to highlight slice when moused over.
+            // This must be false to enable highlightMouseDown to highlight when clicking on an area on a filled plot.
+            this.highlightMouseOver = true;
+            // prop: highlightMouseDown
+            // True to highlight when a mouse button is pressed over a area on a filled plot.
+            // This will be disabled if highlightMouseOver is true.
+            this.highlightMouseDown = false;
+            // prop: highlightColor
+            // color to use when highlighting an area on a filled plot.
+            this.highlightColor = null;
+            // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
+            if (lopts.highlightMouseDown && lopts.highlightMouseOver == null) {
+                lopts.highlightMouseOver = false;
+            }
+        
+            $.extend(true, this, {highlightMouseOver: lopts.highlightMouseOver, highlightMouseDown: lopts.highlightMouseDown, highlightColor: lopts.highlightColor});
+            
+            if (!this.highlightColor) {
+                this.highlightColor = $.jqplot.computeHighlightColors(this.fillColor);
+            }
+            // turn off traditional highlighter
+            if (this.highlighter) {
+                this.highlighter.show = false;
+            }
+            plot.postInitHooks.addOnce(postInit);
+            plot.postDrawHooks.addOnce(postPlotDraw);
+            plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
+            plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
+            plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
+            plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
+            plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
         }
-        
-
-        plot.postInitHooks.addOnce(postInit);
-        plot.postDrawHooks.addOnce(postPlotDraw);
-        plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
-        plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
-        plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
-        plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
-        plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
 
     };
     
         var hctx = this.plugins.lineRenderer.highlightCanvas.setContext();
     } 
     
-    $.jqplot.LineRenderer.prototype.highlightBar = function(ctx, points, options) {
-        
-    };
-    
     function highlight (plot, sidx, pidx, points) {
         var s = plot.series[sidx];
         var canvas = plot.plugins.lineRenderer.highlightCanvas;

File src/plugins/jqplot.trendline.js

         // prop: shadowDepth
         // number of strokes to make of the shadow.
         this.shadowDepth = 3;
+        this.isTrendline = true;
         
     };
     
 
     // called within scope of a series
     function parseTrendLineOptions (seriesDefaults, options) {
-        if (this.renderer.constructor != $.jqplot.PieRenderer) {
+        if (this.renderer.constructor == $.jqplot.LineRenderer) {
             this.trendline = new $.jqplot.Trendline();
             options = options || {};
             $.extend(true, this.trendline, {color:this.color}, seriesDefaults.trendline, options.trendline);
             var data = options.data || this.data;
             fit = fitData(data, this.trendline.type);
             var gridData = options.gridData || this.renderer.makeGridData.call(this, fit.data);
-        
             this.trendline.renderer.draw.call(this.trendline, sctx, gridData, {showLine:true, shadow:this.trendline.shadow});
         }
     }