Skip to content

Commit 862264a

Browse files
authored
Update piechart1.py
1 parent c0ce0b6 commit 862264a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

demo/piechart1.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
(56, "dodgerblue", "CSU"),
3434
(193, "red", "SPD"),
3535
(64, "violetred", "Die Linke"),
36-
(63, "green", "Die Grünen"),
36+
(63, "green", "Die Grünen"),
3737
(1, "gray", "fraktionslos"),
3838
)
3939

@@ -49,18 +49,19 @@
4949

5050
for i, c in enumerate(table):
5151
beta = c[0] / seats * 360 # express no. of seats as angle
52+
color = getColor(c[1]) # avoid multiple color lookups
5253
# the method delivers point of other end of the constructed arc
5354
# we will use it as input for next round
5455
point = page.drawSector(center, point, beta, color = white,
55-
fullSector = True, fill = getColor(c[1]))
56+
fullSector = True, fill = color)
5657
# legend text (takes care of German plural, too)
5758
text = "%s, %i %s" % (c[2], c[0], "Sitze" if c[0] > 1 else "Sitz")
5859
pos = fitz.Point(ts_h, ts_v + i*lineheight)
5960
page.insertText(pos, text, color = blue) # legend text
6061
tl = fitz.Point(pos.x - 30, ts_v - 10 + i*lineheight)
6162
br = fitz.Point(pos.x - 10, ts_v + i*lineheight)
6263
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)
6465

6566
doc.save("piechart1.pdf")
6667

0 commit comments

Comments
 (0)