Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added consistency in inner_radius for pie charts serie graph #486

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions pygal/graph/pie.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def slice(self, serie, start_angle, total):
(self.height - self.margin_box.y) / 2.)

radius = min(center)
hole_radius = radius * serie.inner_radius if serie.inner_radius else 0
if dual:
small_radius = radius * .9
big_radius = radius
else:
big_radius = radius * .9
small_radius = hole_radius
for i, val in enumerate(serie.values):
perc = val / total
if self.half_pie:
Expand All @@ -63,12 +70,6 @@ def slice(self, serie, start_angle, total):
slice_ = decorate(
self.svg, self.svg.node(slices, class_="slice"), metadata
)
if dual:
small_radius = radius * .9
big_radius = radius
else:
big_radius = radius * .9
small_radius = radius * serie.inner_radius

alter(
self.svg.slice(
Expand All @@ -82,7 +83,7 @@ def slice(self, serie, start_angle, total):
val = self._serie_format(serie, sum(serie.values))
self.svg.slice(
serie_node, self.svg.node(slices,
class_="big_slice"), radius * .9, 0,
class_="big_slice"), small_radius, hole_radius,
serie_angle, original_start_angle, center, val, i, metadata
)
return serie_angle
Expand Down