def draw(self, ar): self.type_check() canvas.clip(ar.loc[0], ar.loc[1], ar.loc[0] + ar.size[0], ar.loc[1] + ar.size[1]) if self.direction == "vertical": self.draw_vertical(ar) else: self.draw_horizontal(ar) canvas.endclip()
def draw(self): "Draw the charts." self.type_check() for plot in self._plots: plot.check_integrity() self.x_range, self.x_grid_interval = \ self.__get_data_range(self.x_range, 'X', self.x_coord, self.x_grid_interval) self.y_range, self.y_grid_interval = \ self.__get_data_range(self.y_range, 'Y', self.y_coord, self.y_grid_interval) canvas.rectangle(self.border_line_style, self.bg_style, self.loc[0], self.loc[1], self.loc[0] + self.size[0], self.loc[1] + self.size[1]) if not self.x_grid_over_plot: self.__draw_x_grid_and_axis() if not self.y_grid_over_plot: self.__draw_y_grid_and_axis() canvas.clip(self.loc[0] - 10, self.loc[1] - 10, self.loc[0] + self.size[0] + 10, self.loc[1] + self.size[1] + 10) for plot in self._plots: plot.draw(self) canvas.endclip() if self.x_grid_over_plot: self.__draw_x_grid_and_axis() if self.y_grid_over_plot: self.__draw_y_grid_and_axis() if self.legend == _dummy_legend: self.legend = legend.T() if self.legend: legends = [] for plot in self._plots: entry = plot.get_legend_entry() if entry == None: pass elif type(entry) != types.ListType: legends.append(entry) else: for e in entry: legends.append(e) self.legend.draw(self, legends)
def draw(self, ar): # Draw the line canvas.clip(ar.loc[0], ar.loc[1], ar.loc[0] + ar.size[0], ar.loc[1] + ar.size[1]) if self.line_style: points = [] for pair in self.data: points.append((ar.x_pos(pair[self.xcol]), ar.y_pos(pair[self.ycol]))) canvas.lines(self.line_style, points) canvas.endclip() # Draw tick marks and error bars canvas.clip(ar.loc[0] - 10, ar.loc[1] - 10, ar.loc[0] + ar.size[0] + 10, ar.loc[1] + ar.size[1] + 10) for pair in self.data: x = pair[self.xcol] y = pair[self.ycol] x_pos = ar.x_pos(x) y_pos = ar.y_pos(y) if self.error_bar: plus = pair[self.y_error_plus_col or self.y_error_minus_col] minus = pair[self.y_error_minus_col or self.y_error_plus_col] if self.y_qerror_minus_col or self.y_qerror_plus_col: q_plus = pair[self.y_qerror_minus_col or self.y_qerror_plus_col] q_minus = pair[self.y_qerror_plus_col or self.y_qerror_minus_col] self.error_bar.draw((x_pos, y_pos), ar.y_pos(y - minus), ar.y_pos(y + plus), ar.y_pos(y - q_minus), ar.y_pos(y + q_plus)) else: self.error_bar.draw((x_pos, y_pos), ar.y_pos(y - minus), ar.y_pos(y + plus)) if self.tick_mark: self.tick_mark.draw(x_pos, y_pos) if self.data_label_format: canvas.show(x_pos + self.data_label_offset[0], y_pos + self.data_label_offset[1], "/hC" + pychart_util.apply_format(self.data_label_format, (x, y), 1)) canvas.endclip()
def _decocanvas(self, angle, dp, texrunner): dp.ensurenormpath() dist_pt = unit.topt(self.dist) c = canvas.canvas([canvas.clip(dp.path)]) llx_pt, lly_pt, urx_pt, ury_pt = dp.path.bbox().highrestuple_pt() center_pt = 0.5*(llx_pt+urx_pt), 0.5*(lly_pt+ury_pt) radius_pt = 0.5*math.hypot(urx_pt-llx_pt, ury_pt-lly_pt) + dist_pt n = int(2*radius_pt / dist_pt) + 1 for i in range(n): x_pt = center_pt[0] - radius_pt + i*dist_pt c.stroke(path.line_pt(x_pt, center_pt[1]-radius_pt, x_pt, center_pt[1]+radius_pt), [trafo.rotate_pt(angle, center_pt[0], center_pt[1])] + self.strokestyles) return c
def _decocanvas(self, angle, dp, texrunner): dp.ensurenormpath() dist_pt = unit.topt(self.dist) c = canvas.canvas([canvas.clip(dp.path)]) llx_pt, lly_pt, urx_pt, ury_pt = dp.path.bbox().highrestuple_pt() center_pt = 0.5 * (llx_pt + urx_pt), 0.5 * (lly_pt + ury_pt) radius_pt = 0.5 * math.hypot(urx_pt - llx_pt, ury_pt - lly_pt) + dist_pt n = int(2 * radius_pt / dist_pt) + 1 for i in range(n): x_pt = center_pt[0] - radius_pt + i * dist_pt c.stroke( path.line_pt(x_pt, center_pt[1] - radius_pt, x_pt, center_pt[1] + radius_pt), [trafo.rotate_pt(angle, center_pt[0], center_pt[1])] + self.strokestyles) return c