|
|
@ -41,16 +41,20 @@ class Pie(Graph): |
|
|
|
r=r, |
|
|
|
r=r, |
|
|
|
class_='slice reactive tooltip-trigger') |
|
|
|
class_='slice reactive tooltip-trigger') |
|
|
|
else: |
|
|
|
else: |
|
|
|
rxy = '%f %f' % tuple([r] * 2) |
|
|
|
project = lambda rho, alpha: ( |
|
|
|
to = '%f %f' % (r * sin(angle), r * (1 - cos(angle))) |
|
|
|
rho * sin(-alpha), rho * cos(-alpha)) |
|
|
|
|
|
|
|
diff = lambda x, y: (x[0] - y[0], x[1] - y[1]) |
|
|
|
|
|
|
|
fmt = lambda x: '%f %f' % x |
|
|
|
|
|
|
|
to1 = fmt(diff(center, project(r, start_angle))) |
|
|
|
|
|
|
|
to2 = fmt(diff(center, project(r, start_angle + angle))) |
|
|
|
|
|
|
|
rxy = fmt(tuple([r] * 2)) |
|
|
|
self.svg.node(slice_, 'path', |
|
|
|
self.svg.node(slice_, 'path', |
|
|
|
d='M%s v%f a%s 0 %d 1 %s z' % ( |
|
|
|
d='M%s L%s A%s 0 %d 1 %s z' % ( |
|
|
|
center_str, -r, |
|
|
|
center_str, |
|
|
|
|
|
|
|
to1, |
|
|
|
rxy, |
|
|
|
rxy, |
|
|
|
1 if angle > pi else 0, |
|
|
|
1 if angle > pi else 0, |
|
|
|
to), |
|
|
|
to2), |
|
|
|
transform='rotate(%f %s)' % ( |
|
|
|
|
|
|
|
start_angle * 180 / pi, center_str), |
|
|
|
|
|
|
|
class_='slice reactive tooltip-trigger') |
|
|
|
class_='slice reactive tooltip-trigger') |
|
|
|
self.svg.node(slice_, 'desc').text = val |
|
|
|
self.svg.node(slice_, 'desc').text = val |
|
|
|
text_angle = pi / 2. - (start_angle + angle / 2.) |
|
|
|
text_angle = pi / 2. - (start_angle + angle / 2.) |
|
|
@ -77,14 +81,14 @@ class Pie(Graph): |
|
|
|
self._serie(serie.index), |
|
|
|
self._serie(serie.index), |
|
|
|
current_angle, |
|
|
|
current_angle, |
|
|
|
angle, sum(serie.values) / total) |
|
|
|
angle, sum(serie.values) / total) |
|
|
|
if len(serie.values) > 1: |
|
|
|
# if len(serie.values) > 1: |
|
|
|
small_current_angle = current_angle |
|
|
|
# small_current_angle = current_angle |
|
|
|
for i, val in enumerate(serie.values): |
|
|
|
# for i, val in enumerate(serie.values): |
|
|
|
small_angle = 2 * pi * val / total |
|
|
|
# small_angle = 2 * pi * val / total |
|
|
|
self.slice( |
|
|
|
# self.slice( |
|
|
|
self._serie(serie.index), |
|
|
|
# self._serie(serie.index), |
|
|
|
small_current_angle, |
|
|
|
# small_current_angle, |
|
|
|
small_angle, val / total, |
|
|
|
# small_angle, val / total, |
|
|
|
True) |
|
|
|
# True) |
|
|
|
small_current_angle += small_angle |
|
|
|
# small_current_angle += small_angle |
|
|
|
current_angle += angle |
|
|
|
current_angle += angle |
|
|
|