Пример #1
0
 def draw(self, x, y):
     self.predraw_check()
     # move to the bottom-left corner
     x = x - self.size / 2.0
     y = y - self.size / 2.0
     canvas.rectangle(self.line_style, self.fill_style, x, y, x + self.size,
                      y + self.size)
Пример #2
0
    def draw (self, x, y):
	self.predraw_check()
        # move to the bottom-left corner
        x = x - self.size/2.0
        y = y - self.size/2.0
        canvas.rectangle(self.line_style, self.fill_style,
                         x, y, x+self.size, y+self.size)
Пример #3
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)
Пример #4
0
    def draw(self, ar, entries):
        if not self.loc:
            x = ar.loc[0] + ar.size[0] * 1.1
            y = ar.loc[1]
        else:
            x = self.loc[0]
            y = self.loc[1]

        nr_rows = min(self.nr_rows, len(entries))
        nr_cols = (len(entries) - 1) / nr_rows + 1

        ymin = y
        max_label_width = [0] * nr_cols
        max_sample_width = [0] * nr_cols
        heights = [0] * nr_rows

        for i in range(len(entries)):
            l = entries[i]
            (col, row) = divmod(i, nr_rows)
            max_label_width[col] = max(l.label_width(), max_label_width[col])
            max_sample_width[col] = max(l.sample_width(),
                                        max_sample_width[col])
            heights[row] = max(l.height(), heights[row])

        for h in heights:
            y = y + h
        y = y + self.inter_row_sep * (nr_rows - 1)
        ymax = y

        tot_width = self.inter_col_sep * (nr_cols - 1)
        for w in max_label_width:
            tot_width = tot_width + w
        for w in max_sample_width:
            tot_width = tot_width + w

        canvas.rectangle(self.frame_line_style, self.frame_fill_style,
                         x - self.left_fudge, ymin - self.bottom_fudge,
                         x + tot_width + self.right_fudge,
                         ymax + self.top_fudge, self.shadow)

        for col in range(nr_cols):
            this_y = y
            this_x = x
            for row in range(nr_rows):
                pass
                this_y = this_y - heights[row]
                l = entries[col * nr_cols + row]
                if row != 0:
                    this_y = this_y - self.inter_row_sep

                l.draw(ar, this_x, this_x + max_sample_width[col], this_y)
            x = x + max_label_width[col] + max_sample_width[
                col] + self.inter_col_sep
Пример #5
0
    def draw(self, ar, entries):
        if not self.loc:
            x = ar.loc[0] + ar.size[0] * 1.1
            y = ar.loc[1]
        else:
            x = self.loc[0]
            y = self.loc[1]

        nr_rows = min(self.nr_rows, len(entries))
        nr_cols = (len(entries)-1) / nr_rows + 1
        
        ymin = y
	max_label_width = [0] * nr_cols
        max_sample_width = [0] * nr_cols
        heights = [0] * nr_rows
        
        for i in range(len(entries)):
            l = entries[i]
            (col, row) = divmod(i, nr_rows)
            max_label_width[col] = max(l.label_width(), max_label_width[col])
            max_sample_width[col] = max(l.sample_width(), max_sample_width[col])
            heights[row] = max(l.height(), heights[row])

        for h in heights:
            y = y + h
        y = y + self.inter_row_sep * (nr_rows - 1)
        ymax = y

        tot_width = self.inter_col_sep * (nr_cols -1)
        for w in max_label_width:
            tot_width = tot_width + w
        for w in max_sample_width:
            tot_width = tot_width + w
            
	canvas.rectangle(self.frame_line_style, self.frame_fill_style,
                         x - self.left_fudge,	
                         ymin - self.bottom_fudge,	
                         x + tot_width + self.right_fudge,
                         ymax + self.top_fudge,
			 self.shadow)

        for col in range(nr_cols):
            this_y = y
            this_x = x
            for row in range(nr_rows):
                pass
                this_y = this_y - heights[row]
                l = entries[col * nr_cols + row]
                if row != 0:
                    this_y = this_y - self.inter_row_sep
                    
                l.draw(ar, this_x, this_x + max_sample_width[col], this_y)
            x = x + max_label_width[col] + max_sample_width[col] + self.inter_col_sep
Пример #6
0
    def draw(self, loc, min, max, qmin, qmax):
        x = loc[0]
        style = self.line_style
        y1 = min
        canvas.line(style, x-self.tic_len/2.0, y1, x+self.tic_len/2.0, y1)
        y2 = max
        canvas.line(style, x-self.tic_len/2.0, y2, x+self.tic_len/2.0, y2)
        canvas.line(style, x, y1, x, y2)

        canvas.rectangle(style, self.fill_style,
                         x-self.box_width/2.0, qmin,
                         x+self.box_width/2.0, qmax)
Пример #7
0
    def draw(self, loc, min, max, qmin, qmax):
        x = loc[0]
        style = self.line_style
        y1 = min
        canvas.line(style, x - self.tic_len / 2.0, y1, x + self.tic_len / 2.0,
                    y1)
        y2 = max
        canvas.line(style, x - self.tic_len / 2.0, y2, x + self.tic_len / 2.0,
                    y2)
        canvas.line(style, x, y1, x, y2)

        canvas.rectangle(style, self.fill_style, x - self.box_width / 2.0,
                         qmin, x + self.box_width / 2.0, qmax)
Пример #8
0
    def draw_horizontal(self, ar):
        for pair in self.data:
            yval = pair[self.bcol]
            xval = pair[self.hcol]

            xbot = 0
            if self.stack_on:
                xbot = self.stack_on.get_value(yval)
                xval = xval + xbot

            totalWidth = (self.width+self.cluster_sep) * self.cluster[1] - self.cluster_sep
            firstY = ar.y_pos(yval) - totalWidth/2.0
            thisY = firstY + (self.width+self.cluster_sep) * self.cluster[0] - self.cluster_sep
            canvas.rectangle(self.line_style, self.fill_style,
                             ar.x_pos(xbot), thisY,
                             ar.x_pos(xval), thisY+self.width)
Пример #9
0
    def draw(self, ar, x_tick, x_label, y):
        """Draw a legend entry. X_TICK and X_LABEL are the X location \
        (in points) of where the sample and label are drawn."""

        nr_lines = len(string.split(self.label, "\n"))
        text_height = font.text_height(self.label)[0]
        line_height = text_height / float(nr_lines)
        y_center = y + text_height - line_height / 1.5

        if self.fill_style != None:
            canvas.rectangle(self.line_style, self.fill_style, x_tick,
                             y_center - self.rect_size / 2.0,
                             x_tick + self.rect_size,
                             y_center + self.rect_size / 2.0)
        elif self.line_style != None:
            canvas.line(self.line_style, x_tick, y_center,
                        x_tick + self.line_len, y_center)
            if self.tick_mark != None:
                self.tick_mark.draw(x_tick + self.line_len / 2.0, y_center)
        elif self.tick_mark != None:
            self.tick_mark.draw(x_tick, y_center)

        canvas.show(x_label, y, self.label)
Пример #10
0
 def draw(self, ar, x_tick, x_label, y):
     """Draw a legend entry. X_TICK and X_LABEL are the X location \
     (in points) of where the sample and label are drawn."""
     
     nr_lines = len(string.split(self.label, "\n"))
     text_height = font.text_height(self.label)[0]
     line_height = text_height / float(nr_lines)
     y_center = y + text_height - line_height/1.5
         
     if self.fill_style != None:
         canvas.rectangle(self.line_style, self.fill_style,
                          x_tick, y_center - self.rect_size/2.0,
                          x_tick + self.rect_size,
                          y_center + self.rect_size/2.0)
     elif self.line_style != None:
         canvas.line(self.line_style, x_tick, y_center,
                     x_tick + self.line_len, y_center)
         if self.tick_mark != None:
             self.tick_mark.draw(x_tick + self.line_len/2.0, y_center)
     elif self.tick_mark != None:
         self.tick_mark.draw(x_tick, y_center)
         
     canvas.show(x_label, y, self.label)
Пример #11
0
    def draw_vertical(self, ar):
        for pair in self.data:
            xval = pair[self.bcol]
            yval = pair[self.hcol]

            ybot = 0
            if self.stack_on:
                ybot = self.stack_on.get_value(xval)
                yval = yval + ybot

            totalWidth = (self.width+self.cluster_sep) * self.cluster[1] - self.cluster_sep
            firstX = ar.x_pos(xval) - totalWidth/2.0
            thisX = firstX + (self.width+self.cluster_sep) * self.cluster[0] - self.cluster_sep

            canvas.rectangle(self.line_style, self.fill_style,
                             thisX, ar.y_pos(ybot), thisX+self.width, 
                             ar.y_pos(yval))

            if self.error_bar:
                plus = pair[self.error_minus_col or self.error_plus_col]
                minus = pair[self.error_plus_col or self.error_minus_col]
                qplus = 0
                qminus = 0
                if self.qerror_minus_col or self.qerror_plus_col:
                    qplus = pair[self.qerror_minus_col or self.qerror_plus_col]
                    qminus = pair[self.qerror_plus_col or self.qerror_minus_col]
                self.error_bar.draw((thisX+self.width/2.0, ar.y_pos(yval)),
                                    ar.y_pos(yval - qminus),
                                    ar.y_pos(yval + qplus),
                                    ar.y_pos(yval - minus),
                                    ar.y_pos(yval + plus))
                    
            if self.data_label_format:
                canvas.show(thisX + self.width/2.0 + self.data_label_offset[0],
                            ar.y_pos(yval) + self.data_label_offset[1],
                            "/hC" + pychart_util.apply_format(self.data_label_format, (pair[self.bcol], pair[self.hcol]), 1))