|
|
@ -32,8 +32,10 @@ class Pie(Graph): |
|
|
|
(self.height - self.margin.y) / 2.) |
|
|
|
(self.height - self.margin.y) / 2.) |
|
|
|
r = min(center) |
|
|
|
r = min(center) |
|
|
|
if small: |
|
|
|
if small: |
|
|
|
r *= .9 |
|
|
|
small_r = r * .9 |
|
|
|
center_str = '%f %f' % center |
|
|
|
else: |
|
|
|
|
|
|
|
r = r * .9 |
|
|
|
|
|
|
|
small_r = 0 |
|
|
|
if perc == 1: |
|
|
|
if perc == 1: |
|
|
|
self.svg.node(slice_, 'circle', |
|
|
|
self.svg.node(slice_, 'circle', |
|
|
|
cx=center[0], |
|
|
|
cx=center[0], |
|
|
@ -45,18 +47,27 @@ class Pie(Graph): |
|
|
|
rho * sin(-alpha), rho * cos(-alpha)) |
|
|
|
rho * sin(-alpha), rho * cos(-alpha)) |
|
|
|
diff = lambda x, y: (x[0] - y[0], x[1] - y[1]) |
|
|
|
diff = lambda x, y: (x[0] - y[0], x[1] - y[1]) |
|
|
|
fmt = lambda x: '%f %f' % x |
|
|
|
fmt = lambda x: '%f %f' % x |
|
|
|
to1 = fmt(diff(center, project(r, start_angle))) |
|
|
|
get_radius = lambda r: fmt(tuple([r] * 2)) |
|
|
|
to2 = fmt(diff(center, project(r, start_angle + angle))) |
|
|
|
absolute_project = lambda rho, theta: fmt( |
|
|
|
rxy = fmt(tuple([r] * 2)) |
|
|
|
diff(center, project(rho, theta))) |
|
|
|
|
|
|
|
to1 = absolute_project(r, start_angle) |
|
|
|
|
|
|
|
to2 = absolute_project(r, start_angle + angle) |
|
|
|
|
|
|
|
to3 = absolute_project(small_r, start_angle + angle) |
|
|
|
|
|
|
|
to4 = absolute_project(small_r, start_angle) |
|
|
|
self.svg.node(slice_, 'path', |
|
|
|
self.svg.node(slice_, 'path', |
|
|
|
d='M%s L%s A%s 0 %d 1 %s z' % ( |
|
|
|
d='M%s A%s 0 %d 1 %s L%s A%s 0 %d 0 %s z' % ( |
|
|
|
center_str, |
|
|
|
|
|
|
|
to1, |
|
|
|
to1, |
|
|
|
rxy, |
|
|
|
get_radius(r), int(angle > pi), to2, |
|
|
|
1 if angle > pi else 0, |
|
|
|
to3, |
|
|
|
to2), |
|
|
|
get_radius(small_r), int(angle > pi), to4), |
|
|
|
class_='slice reactive tooltip-trigger') |
|
|
|
class_='slice reactive tooltip-trigger') |
|
|
|
self.svg.node(slice_, 'desc').text = val |
|
|
|
self.svg.node(slice_, 'desc', class_="value").text = val |
|
|
|
|
|
|
|
tooltip_position = map( |
|
|
|
|
|
|
|
str, diff(center, project( |
|
|
|
|
|
|
|
(r + small_r) / 2., start_angle + angle / 2.))) |
|
|
|
|
|
|
|
self.svg.node(slice_, 'desc', class_="x").text = tooltip_position[0] |
|
|
|
|
|
|
|
self.svg.node(slice_, 'desc', class_="y").text = tooltip_position[1] |
|
|
|
|
|
|
|
|
|
|
|
text_angle = pi / 2. - (start_angle + angle / 2.) |
|
|
|
text_angle = pi / 2. - (start_angle + angle / 2.) |
|
|
|
text_r = r * .95 |
|
|
|
text_r = r * .95 |
|
|
|
self.svg.node(serie_node['text_overlay'], 'text', |
|
|
|
self.svg.node(serie_node['text_overlay'], 'text', |
|
|
@ -81,14 +92,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 |
|
|
|