Skip to content
mgrdcm edited this page Mar 10, 2011 · 2 revisions

In an older version of this, it redirected directly to Google Charts to save time and resources. Here's the code that was removed (now lost because that was in an old repo that has now been deleted):

  def begin_lines(self, height, lineheight):
        linefeeds = ''

        for i in range(0, int(math.floor(((height-lineheight)/2)/lineheight)) ):
            linefeeds += '|'

        return linefeeds;
         ## if the image is small enough for Google Charts to handle, we'll just redirect directly to a GC URL
         if width <= 1000 and height <= 1000 and width*height <= 300000:
             url = 'http://chart.apis.google.com/chart?chs=' + dimensions + '&cht=p3&chtt=' + self.begin_lines(height, title_font_size + line_height_fudge) +  label + '&chts=000000,' + str(title_font_size) + '&chf=bg,s,' + bgcolor
         
             if (mimetype == 'image/png'):
                 self.redirect(url)
             else:
                 img = fetch(url)
         
                 self.response.headers['Content-Type'] = mimetype
         
                 if img.headers['Content-Type'] == mimetype:
                     self.response.out.write(img.content)
                 else:
                     self.response.out.write(images.resize(img.content, width=width, height=height, output_encoding=encoding))
         
         
         ## next we'll try compositing a GC-generated label onto a blank background up to the 4000x4000 GAE limit
         elif width <= 4000 and height <= 4000:
        #NEW# if width <= 4000 and height <= 4000:
Clone this wiki locally