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)
import coord import line_style import legend import axis import pychart_util import chart_object import fill_style import types import math import canvas import area_doc import linear_coord import category_coord _dummy_legend = legend.T() zigZagSize=30 _keys = { "loc" : (pychart_util.CoordType, 0, (0,0), """The location of the bottom-left corner of the chart. @cindex chart location @cindex location, chart."""), "size" : (pychart_util.CoordType, 0, (120,110), """The size of the chart-drawing area, excluding axis labels, legends, tick marks, etc. @cindex chart size @cindex size, chart """), "bg_style": (fill_style.T, 1, None, "Background fill-pattern."), "border_line_style": (line_style.T, 1, None, "Line style of the outer frameof the chart."),
def draw(self, can=None): "Draw the charts." if can == None: can = canvas.default_canvas() assert self.check_integrity() 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) can.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(can) if not self.y_grid_over_plot: self.__draw_y_grid_and_axis(can) clipbox = theme.adjust_bounding_box([ self.loc[0], self.loc[1], self.loc[0] + self.size[0], self.loc[1] + self.size[1] ]) can.clip(clipbox[0], clipbox[1], clipbox[2], clipbox[3]) for plot in self.__plots: plot.draw(self, can) can.endclip() if self.x_grid_over_plot: self.__draw_x_grid_and_axis(can) if self.y_grid_over_plot: self.__draw_y_grid_and_axis(can) 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) != ListType: legends.append(entry) else: for e in entry: legends.append(e) self.legend.draw(self, legends, can)