def DrawToFile(self, height, width, outfn, ignore_grey, ignore_colour, label, ignore_lightness=False, ignore_saturation=False): image = Image.new('RGB', (width + 2, height + 2)) canvas = ImageDraw.Draw(image) self.DrawOnCanvas(height + 2, width + 2, 0, canvas, ignore_grey, ignore_colour, label=label, ignore_lightness=ignore_lightness, ignore_saturation=ignore_saturation) del canvas print 'writing to %s' % outfn image.save(outfn, 'PNG') cnames = [] ccolours = [] ccounts = [] tt = sum(self._colour_counts.values()) for (k, v) in sorted(self._colour_counts.items()): pct = 100.0 * v / tt cnames.append(HUE_DEGREES_NAME[k] + '(%2.1f%%)' % pct) ccolours.append(get_html_colour_from_hue(k)) ccounts.append(pct) # PRINT PIE CHART try: pc = Pie(ccounts).title( 'Colour distribution for %s' % label).color(*ccolours).label(*cnames).size(650, 400) return pc.url except: return '#'
#!/usr/bin/env python from GChartWrapper import Pie chart = Pie([20, 10]) chart.title('Hello GChartWrapper') chart.label('hello', 'world') chart.save('pie_en.png')
#!/usr/bin/env python3 from GChartWrapper import Pie chart = Pie([20, 10]) chart.title('안녕 GChartWrapper') chart.label('안녕', '세상') chart.save('pie_ko.png')