| 
33 | 33 |           (56, "dodgerblue", "CSU"),  | 
34 | 34 |           (193, "red", "SPD"),  | 
35 | 35 |           (64, "violetred", "Die Linke"),  | 
36 |  | -          (63, "green", "Die Grünen"),  | 
 | 36 | +          (63, "green", "Die Grünen"),  | 
37 | 37 |           (1, "gray", "fraktionslos"),  | 
38 | 38 |          )  | 
39 | 39 | 
 
  | 
 | 
49 | 49 | 
 
  | 
50 | 50 | for i, c in enumerate(table):  | 
51 | 51 |     beta = c[0] / seats * 360          # express no. of seats as angle  | 
 | 52 | +    color = getColor(c[1])             # avoid multiple color lookups  | 
52 | 53 |     # the method delivers point of other end of the constructed arc  | 
53 | 54 |     # we will use it as input for next round  | 
54 | 55 |     point = page.drawSector(center, point, beta, color = white,  | 
55 |  | -                    fullSector = True, fill = getColor(c[1]))  | 
 | 56 | +                    fullSector = True, fill = color)  | 
56 | 57 |     # legend text (takes care of German plural, too)  | 
57 | 58 |     text = "%s, %i %s" % (c[2], c[0], "Sitze" if c[0] > 1 else "Sitz")  | 
58 | 59 |     pos  = fitz.Point(ts_h, ts_v + i*lineheight)  | 
59 | 60 |     page.insertText(pos, text, color = blue)     # legend text  | 
60 | 61 |     tl = fitz.Point(pos.x - 30, ts_v - 10 + i*lineheight)  | 
61 | 62 |     br = fitz.Point(pos.x - 10, ts_v + i*lineheight)  | 
62 | 63 |     rect = fitz.Rect(tl, br)                # legend color bar  | 
63 |  | -    page.drawRect(rect, fill = getColor(c[1]), color = getColor(c[1]))  | 
 | 64 | +    page.drawRect(rect, fill = color, color = color)  | 
64 | 65 | 
 
  | 
65 | 66 | doc.save("piechart1.pdf")  | 
66 | 67 | 
 
  | 
 | 
0 commit comments