Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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()