def draw(self, ar): center = self.center if not center: center = (ar.loc[0] + ar.size[0] / 2.0, ar.loc[1] + ar.size[1] / 2.0) radius = self.radius if not radius: radius = min(ar.size[0] / 2.0, ar.size[1] / 2.0) * 0.5 label_offset = radius + (self.label_offset or radius * 0.1) total = self._total() i = 0 cur_angle = self.start_angle for val in self.data: fill = self.fill_styles[i] degree = 360 * float(val[self.data_col]) / float(total) off = (0, 0) if len(self.arc_offsets) > i: off = pychart_util.rotate(self.arc_offsets[i], 0, cur_angle - degree / 2.0) x_center = center[0] + off[0] y_center = center[1] + off[1] canvas.ellipsis(self.line_style, fill, x_center, y_center, radius, 1, cur_angle - degree, cur_angle, self.shadow) label = val[self.label_col] (x_label, y_label) = pychart_util.rotate(label_offset, 0, cur_angle - degree / 2.0) (x_arrowtip, y_arrowtip) = pychart_util.rotate(radius, 0, cur_angle - degree / 2.0) # Labels on left side of pie need # their text to avoid obscuring the pie if x_label < 0: x_label = x_label - font.text_width(label) t = text_box.T(loc=(x_label + x_center, y_label + y_center), text=label, line_style=self.label_line_style, fill_style=self.label_fill_style) if self.arrow_style: t.add_arrow((x_arrowtip + x_center, y_arrowtip + y_center), None, self.arrow_style) t.draw() cur_angle = (cur_angle - degree) % 360 i = (i + 1) % len(self.fill_styles)
def draw(self, ar): center = self.center if not center: center = (ar.loc[0] + ar.size[0]/2.0, ar.loc[1] + ar.size[1]/2.0) radius = self.radius if not radius: radius = min(ar.size[0]/2.0, ar.size[1]/2.0) * 0.5 label_offset = radius + (self.label_offset or radius * 0.1) total = self._total() i = 0 cur_angle = self.start_angle for val in self.data: fill = self.fill_styles[i] degree = 360 * float(val[self.data_col]) / float(total) off = (0, 0) if len(self.arc_offsets) > i: off = pychart_util.rotate(self.arc_offsets[i], 0, cur_angle - degree/2.0) x_center = center[0]+ off[0] y_center = center[1]+ off[1] canvas.ellipsis(self.line_style, fill, x_center, y_center, radius, 1, cur_angle - degree, cur_angle, self.shadow) label = val[self.label_col] (x_label, y_label) = pychart_util.rotate(label_offset, 0, cur_angle - degree/2.0) (x_arrowtip, y_arrowtip) = pychart_util.rotate(radius, 0, cur_angle - degree/2.0) # Labels on left side of pie need # their text to avoid obscuring the pie if x_label < 0: x_label = x_label - font.text_width(label) t = text_box.T(loc = (x_label + x_center, y_label + y_center), text = label, line_style = self.label_line_style, fill_style = self.label_fill_style) if self.arrow_style: t.add_arrow((x_arrowtip + x_center, y_arrowtip + y_center), None, self.arrow_style) t.draw() cur_angle = (cur_angle - degree) % 360 i = (i + 1) % len(self.fill_styles)
def draw(self, x, y): self.predraw_check() canvas.ellipsis(self.line_style, self.fill_style, x, y, self.size / 2.0, 1)
def draw (self, x, y): self.predraw_check() canvas.ellipsis(self.line_style, self.fill_style, x, y, self.size/2.0, 1)