Commits

Anonymous committed 6736fc3

Fixed clipping in image export in certain cases and don't draw legend border in export if width is 0.

Comments (0)

Files changed (1)

src/jqplot.toImage.js

         var plotleft = $(this).offset().left;
         var plottop = $(this).offset().top;
         var transx = 0, transy = 0;
+        // var tlw = tlh = tll = tlr = tlt = tlb = 0;
         // console.log("chart: height: %s, width: %s, left: %s, top: %s, transx: %s, transy: %s", h, w, plotleft, plottop, transx, transy);
 
         // have to check if any elements are hanging outside of plot area before rendering,
             $(this).find('.'+clses[i]).each(function() {
                 temptop = $(this).offset().top - plottop;
                 templeft = $(this).offset().left - plotleft;
-                tempright = templeft + $(this).outerWidth(true);
-                tempbottom = temptop + $(this).outerHeight(true);
+                tempright = templeft + $(this).outerWidth(true) + transx;
+                tempbottom = temptop + $(this).outerHeight(true) + transy;
                 if (templeft < -transx) {
                     w = w - transx - templeft;
                     transx = -templeft;
                 if (tempbottom > h) {
                     h =  tempbottom;
                 }
+                // console.log(this.tagName);
+                // console.log(temptop, templeft, tempright, tempbottom);
+                // console.log(w, h, transx, transy);
             })
         }
         // console.log("chart: height: %s, width: %s, left: %s, top: %s, transx: %s, transy: %s", h, w, plotleft, plottop, transx, transy);
                 newContext.strokeStyle = $(el).css('border-top-color');
                 newContext.fillStyle = $(el).css('background-color');
                 newContext.fillRect(left, top, $(el).innerWidth(), $(el).innerHeight());
-                newContext.strokeRect(left, top, $(el).innerWidth(), $(el).innerHeight());
+                if (parseInt($(el).css('border-top-width')) > 0) {
+                    newContext.strokeRect(left, top, $(el).innerWidth(), $(el).innerHeight());
+                }