Commits

Anonymous committed 2f3b105

Refactored error handling customization options. Now have option to throw error normally and not handle.

Comments (0)

Files changed (2)

src/jqplot.core.js

             return plot;
         }
         catch(e) {
-            var msg = $.jqplot.config.ErrorMessage || e.message;
-            $('#'+target).append('<div style="text-align:center;position:relative;top:50%;">'+msg+'</div>');
-            $('#'+target).css({background: $.jqplot.config.ErrorBackground, border: $.jqplot.config.ErrorBorder, font: $.jqplot.config.ErrorFont});
+            if ($.jqplot.config.catchErrors) {
+                var msg = $.jqplot.config.errorMessage || e.message;
+                $('#'+target).append('<div style="text-align:center;position:relative;top:50%;">'+msg+'</div>');
+                $('#'+target).css({background: $.jqplot.config.errorBackground, border: $.jqplot.config.errorBorder, font: $.jqplot.config.errorFont});
+            }
+            else {
+                throw e.message;
+            }
         }
     };
         
         defaultWidth:400,
         UTCAdjust:false,
         timezoneOffset: new Date(new Date().getTimezoneOffset() * 60000),
-        ErrorMessage: '',
-        ErrorBackground: '#fffbf9',
-        ErrorBorder: '1px solid #f6dccb',
-        ErrorFont: ''
+        errorMessage: '',
+        errorBackground: '',
+        errorBorder: '',
+        errorFont: '',
+        catchErrors: false
     };
     
     $.jqplot.enablePlugins = $.jqplot.config.enablePlugins;
                 data = this._plotData;
             }
             var gridData = options.gridData || this.renderer.makeGridData.call(this, data, plot);
-            this.renderer.draw.call(this, sctx, gridData, options);
+            this.renderer.draw.call(this, sctx, gridData, options, plot);
         }
         
         for (var j=0; j<$.jqplot.postDrawSeriesHooks.length; j++) {

src/plugins/jqplot.pieRenderer.js

         // prop: highlightColors
         // an array of colors to use when highlighting a slice.
         this.highlightColors = [];
+        // prop: dataLabels
+        // Array of labels to place on the pie slices.
+        // Defaults to percentage of each pie slice.
+        this.dataLabels = [];
+        // prop: showDataLabels
+        // true to show data labels on slices.
+        this.showDataLabels = true;
         // prop: startAngle
         // Angle to start drawing pie in degrees.  
         // According to orientation of canvas coordinate system:
         return td;
     };
     
-    $.jqplot.PieRenderer.prototype.drawSlice = function (ctx, ang1, ang2, color, isShadow) {
+    $.jqplot.PieRenderer.prototype.drawSlice = function (ctx, ang1, ang2, color, isShadow, plot) {
         var r = this._diameter / 2;
         var fill = this.fill;
         var lineWidth = this.lineWidth;
     };
     
     // called with scope of series
-    $.jqplot.PieRenderer.prototype.draw = function (ctx, gd, options) {
+    $.jqplot.PieRenderer.prototype.draw = function (ctx, gd, options, plot) {
         var i;
         var opts = (options != undefined) ? options : {};
         // offset and direction of offset due to legend placement
             // Adjust ang1 and ang2 for sliceMargin
             ang1 += this.sliceMargin/180*Math.PI;
             this._sliceAngles.push([ang1, gd[i][1]+sa]);
-            this.renderer.drawSlice.call (this, ctx, ang1, gd[i][1]+sa, this.seriesColors[i]);
+            this.renderer.drawSlice.call (this, ctx, ang1, gd[i][1]+sa, this.seriesColors[i], plot);
         }
                
     };