Ejemplo n.º 1
0
    def draw_above(self, ar, can):
        y_base = ar.loc[1] + self.offset

        tic_dic = {}
        max_tic_height = 0

        for i in ar.x_tic_points(self.tic_interval):
            tic_dic[i] = 1
            ticx = ar.x_pos(i)

            str = "/hC" + pychart_util.apply_format(self.format, (i, ), 0)

            (total_height, base_height) = font.text_height(str)
            max_tic_height = max(max_tic_height, total_height)

            can.line(self.line_style, ticx, y_base, ticx,
                     y_base + self.tic_len)
            can.show(
                ticx + self.tic_label_offset[0],
                y_base + self.tic_len + base_height + self.tic_label_offset[1],
                str)

        if self.minor_tic_interval:
            for i in ar.x_tic_points(self.minor_tic_interval):
                if tic_dic.has_key(i):
                    # a major tic was drawn already.
                    pass
                else:
                    ticx = ar.x_pos(i)
                    can.line(self.line_style, ticx, y_base, ticx,
                             y_base + self.minor_tic_len)
        self.draw_label(ar, can, y_base + self.tic_len + max_tic_height + 10)
Ejemplo n.º 2
0
    def draw_horizontal(self, ar, can):
        for pair in self.data:
            yval = pair[self.bcol]
            xval = pychart_util.get_sample_val(pair, self.hcol)

            if None in (xval, yval): continue

            xbot = 0
            if self.stack_on:
                xbot = self.stack_on.get_value(yval)
                xval += xbot
            totalWidth = self.get_bar_width(ar, self.cluster[1])
            firstY = ar.y_pos(yval) - totalWidth / 2.0
            thisY = firstY + self.get_bar_width(ar, self.cluster[0])

            can.rectangle(self.line_style, self.fill_style, ar.x_pos(xbot),
                          thisY, ar.x_pos(xval), thisY + self.width)

            if self.data_label_format:
                can.show(
                    ar.x_pos(xval) + self.data_label_offset[0],
                    thisY + self.width / 2.0 + self.data_label_offset[1],
                    "/vM/hL" + pychart_util.apply_format(
                        self.data_label_format,
                        (pair[self.bcol], pair[self.hcol]), 1))
Ejemplo n.º 3
0
    def draw_right(self, ar, can):
        x_base = ar.loc[0] + self.offset
        xmax = 0
        tic_dic = {}
        for i in ar.y_tic_points(self.tic_interval):
            y_tic = ar.y_pos(i)
            tic_dic[i] = 1
            can.line(self.line_style, x_base, y_tic, x_base + self.tic_len,
                     y_tic)
            str = pychart_util.apply_format(self.format, (i, ), 0)
            if self.tic_len > 0: str = "/hL" + str

            tic_height, base_height = font.text_height(str)
            x = x_base + self.tic_len + self.tic_label_offset[0]
            can.show(x, y_tic - tic_height / 2.0 + self.tic_label_offset[1],
                     str)
            xmax = max(xmax, x + font.text_width(str))

        if self.minor_tic_interval:
            for i in ar.y_tic_points(self.minor_tic_interval):
                if tic_dic.has_key(i):
                    # a major tic line was drawn already.
                    pass
                else:
                    y_tic = ar.y_pos(i)
                    can.line(self.line_style, x_base, y_tic,
                             x_base + self.minor_tic_len, y_tic)

        self.draw_label(ar, can, xmax + theme.default_font_size)
Ejemplo n.º 4
0
Archivo: axis.py Proyecto: Scemoon/lpts
    def draw_right(self, ar, can):
        x_base = ar.loc[0] + self.offset
        xmax = 0
        tic_dic = {}
        for i in ar.y_tic_points(self.tic_interval):
            y_tic = ar.y_pos(i)
            tic_dic[i] = 1
            can.line(self.line_style, x_base, y_tic,
                     x_base + self.tic_len, y_tic)
            string = pychart_util.apply_format(self.format, (i,), 0)
            if self.tic_len > 0: string = "/hL" + string

            tic_height, base_height = font.text_height(string)
            x = x_base + self.tic_len + self.tic_label_offset[0]
            can.show(x, y_tic - tic_height/2.0 + self.tic_label_offset[1],
                     string)
            xmax = max(xmax, x + font.text_width(string))
            
        if self.minor_tic_interval:
            for i in ar.y_tic_points(self.minor_tic_interval):
                if tic_dic.has_key(i):
                    # a major tic line was drawn already.
                    pass
                else:
                    y_tic = ar.y_pos(i)
                    can.line(self.line_style, x_base, y_tic,
                             x_base + self.minor_tic_len, y_tic)

        self.draw_label(ar, can, xmax + theme.default_font_size)
Ejemplo n.º 5
0
    def draw_vertical(self, ar, can):
        for pair in self.data:
            xval = pair[self.bcol]
            yvals = pychart_util.get_sample_val(pair, self.hcol)

            if None in (xval, yvals): continue

            ybot = 0

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

            cury = yvals[0]
            n = 0

            for yval in yvals[1:]:
                (line_style, fill_style) = self.get_style(n)
                can.rectangle(line_style, fill_style, this_x, ar.y_pos(cury),
                              this_x + self.width, ar.y_pos(cury + yval))
                cury += yval
                n += 1

                if self.data_label_format:
                    can.show(
                        this_x + self.width / 2.0 + self.data_label_offset[0],
                        ar.y_pos(cury) + self.data_label_offset[1],
                        "/hC" + pychart_util.apply_format(
                            self.data_label_format,
                            (pair[self.bcol], pair[self.hcol]), 1))
    def draw_vertical(self, ar, can):
        for pair in self.data:
            xval = pair[self.bcol]
            yvals = pychart_util.get_sample_val(pair, self.hcol)
            
            if None in (xval, yvals): continue

            ybot = 0
            
            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

            cury = yvals[0]
            n = 0
            
            for yval in yvals[1:]:
                (line_style, fill_style) = self.get_style(n)
                can.rectangle(line_style, fill_style,
                              thisX, ar.y_pos(cury), thisX+self.width, 
                              ar.y_pos(cury + yval))
                cury += yval
                n += 1
                
                if self.data_label_format:
                    can.show(thisX + self.width/2.0 + self.data_label_offset[0],
                             ar.y_pos(cury) + self.data_label_offset[1],
                             "/hC" + pychart_util.apply_format(self.data_label_format, (pair[self.bcol], pair[self.hcol]), 1))
Ejemplo n.º 7
0
    def draw_above(self, ar, can):
        y_base = ar.loc[1] + self.offset
      
        tic_dic = {}
        max_tic_height = 0
      
        for i in ar.x_tic_points(self.tic_interval):
            tic_dic[i] = 1
            ticx = ar.x_pos(i)

            str = "/hC" + pychart_util.apply_format(self.format, (i, ), 0)

            (total_height, base_height) = font.text_height(str)
            max_tic_height = max(max_tic_height, total_height)

            can.line(self.line_style, ticx, y_base, ticx, y_base + self.tic_len)
            can.show(ticx+self.tic_label_offset[0], 
                     y_base + self.tic_len + base_height + self.tic_label_offset[1],
                     str)
         
        if self.minor_tic_interval:
            for i in ar.x_tic_points(self.minor_tic_interval):
                if tic_dic.has_key(i):
                    # a major tic was drawn already.
                    pass
                else:
                    ticx = ar.x_pos(i)
                    can.line(self.line_style, ticx, y_base, ticx,
                             y_base + self.minor_tic_len)
        self.draw_label(ar, can, y_base + self.tic_len + max_tic_height + 10)
Ejemplo n.º 8
0
    def draw(self, ar, can):

        # Draw the line

        clipbox = theme.adjust_bounding_box([ar.loc[0], ar.loc[1], ar.loc[0] + ar.size[0], ar.loc[1] + ar.size[1]])

        can.clip(clipbox[0], clipbox[1], clipbox[2], clipbox[3])
        if self.line_style:
            points = []
            for pair in self.data:
                yval = pychart_util.get_sample_val(pair, self.ycol)
                xval = pair[self.xcol]
                if None not in (xval, yval):
                    points.append((ar.x_pos(xval), ar.y_pos(yval)))
            can.lines(self.line_style, points)
        can.endclip()

        # Draw tick marks and error bars
        can.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 = pychart_util.get_sample_val(pair, self.ycol)
            if None in (x, y):
                continue

            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_plus_col or self.y_qerror_minus_col]
                    q_minus = pair[self.y_qerror_minus_col or self.y_qerror_plus_col]
                    if None not in (minus, plus, q_minus, q_plus):
                        self.error_bar.draw(
                            can,
                            (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:
                    if None not in (minus, plus):  # PDS
                        self.error_bar.draw(can, (x_pos, y_pos), ar.y_pos(y - minus), ar.y_pos(y + plus))

            if self.tick_mark:
                self.tick_mark.draw(can, x_pos, y_pos)
            if self.data_label_format:
                can.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),
                )

        can.endclip()
Ejemplo n.º 9
0
    def draw(self, ar, can):

        # Draw the line

        clipbox = theme.adjust_bounding_box([ar.loc[0], ar.loc[1],
                                             ar.loc[0] + ar.size[0],
                                             ar.loc[1] + ar.size[1]]);
        
        can.clip(clipbox[0],clipbox[1],clipbox[2],clipbox[3])
        if self.line_style:
            points = []
            for pair in self.data:
                yval = pychart_util.get_sample_val(pair, self.ycol)
                xval = pair[self.xcol]
                if None not in (xval, yval):
                    points.append((ar.x_pos(xval), ar.y_pos(yval)))
            can.lines(self.line_style, points)
        can.endclip()
        
        # Draw tick marks and error bars
        can.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 = pychart_util.get_sample_val(pair, self.ycol)
            if None in (x, y): continue
            
            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_plus_col or self.y_qerror_minus_col]
                    q_minus = pair[self.y_qerror_minus_col or self.y_qerror_plus_col]
                    if None not in (minus,plus,q_minus,q_plus):
                        self.error_bar.draw(can, (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:
                    if None not in (minus,plus): #PDS
                        self.error_bar.draw(can, (x_pos, y_pos),
                                            ar.y_pos(y - minus),
                                            ar.y_pos(y + plus))
                        
            if self.tick_mark:
                self.tick_mark.draw(can, x_pos, y_pos)
            if self.data_label_format:
                can.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))

        can.endclip()
Ejemplo n.º 10
0
    def draw(self, ar, can):
        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]

            can.ellipsis(self.line_style, fill, x_center, y_center, radius, 1,
                         cur_angle - degree, cur_angle, self.shadow)

            label = pychart_util.apply_format(self.label_format, val,
                                              self.label_col)
            if label != None:
                (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(can)
            cur_angle = (cur_angle - degree) % 360
            i = (i + 1) % len(self.fill_styles)
Ejemplo n.º 11
0
    def draw(self, ar, can):
        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]
            
            can.ellipsis(self.line_style, fill,
                         x_center, y_center, radius, 1,
                         cur_angle - degree, cur_angle,
                         self.shadow)

            label = pychart_util.apply_format(self.label_format, val,
                                              self.label_col)
            if label != None:
                (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(can)
            cur_angle = (cur_angle - degree) % 360
            i = (i + 1) % len(self.fill_styles)
Ejemplo n.º 12
0
Archivo: axis.py Proyecto: zhyh329/lpts
    def draw_tics_and_labels(self, ar, can):
        #assert self.check_integrity()
        y_base = ar.loc[1] + self.offset
        self.tic_interval = self.tic_interval or ar.x_grid_interval

        can.line(self.line_style, ar.loc[0], y_base, ar.loc[0] + ar.size[0],
                 y_base)

        tic_dic = {}
        max_tic_height = 0
        if self.draw_tics_above:
            sign = 1
        else:
            sign = -1
        if self.x_list:
            tic_list = self.x_list
        else:
            tic_list = ar.x_tic_points(self.tic_interval)
        for i in tic_list:
            tic_dic[i] = 1
            ticx = ar.x_pos(i)

            string = "/hC" + pychart_util.apply_format(self.format, (i, ), 0)

            (total_height, base_height) = font.text_height(string)
            max_tic_height = max(max_tic_height, total_height)
            if self.draw_tics_above:
                base_height = 0

            can.line(self.line_style, ticx, y_base, ticx,
                     y_base + sign * self.tic_len)
            can.show(
                ticx + self.tic_label_offset[0], y_base + sign *
                (self.tic_len + base_height) + self.tic_label_offset[1],
                string)

        if self.minor_tic_interval:
            for i in ar.x_tic_points(self.minor_tic_interval):
                if tic_dic.has_key(i):
                    # a major tic was drawn already.
                    pass
                else:
                    ticx = ar.x_pos(i)
                    can.line(self.line_style, ticx, y_base, ticx,
                             y_base + sign * self.minor_tic_len)

        self.draw_label(ar, can,
                        (y_base + sign * (self.tic_len + max_tic_height + 10)))
Ejemplo n.º 13
0
Archivo: axis.py Proyecto: Scemoon/lpts
    def draw_tics_and_labels(self, ar, can):
        #assert self.check_integrity()
        y_base = ar.loc[1] + self.offset
        self.tic_interval = self.tic_interval or ar.x_grid_interval

        can.line(self.line_style, ar.loc[0], y_base,
                 ar.loc[0]+ ar.size[0], y_base)

        tic_dic = {}
        max_tic_height = 0
        if self.draw_tics_above:
            sign = 1
        else:
            sign = -1
        if self.x_list:
	    tic_list = self.x_list
        else:
            tic_list = ar.x_tic_points(self.tic_interval) 
        for i in tic_list:
            tic_dic[i] = 1
            ticx = ar.x_pos(i)

            string = "/hC" + pychart_util.apply_format(self.format, (i, ), 0)

            (total_height, base_height) = font.text_height(string)
            max_tic_height = max(max_tic_height, total_height)
            if self.draw_tics_above:
                base_height = 0

            can.line(self.line_style, ticx, y_base,
                     ticx, y_base + sign * self.tic_len)
            can.show(ticx + self.tic_label_offset[0], 
                     y_base + sign * (self.tic_len + base_height) + self.tic_label_offset[1],
                     string)
         
        if self.minor_tic_interval:
            for i in ar.x_tic_points(self.minor_tic_interval):
                if tic_dic.has_key(i):
                    # a major tic was drawn already.
                    pass
                else:
                    ticx = ar.x_pos(i)
                    can.line(self.line_style, ticx, y_base,
                             ticx, y_base + sign * self.minor_tic_len)

        self.draw_label(ar, can, (y_base + sign * 
                                  (self.tic_len + max_tic_height + 10)))
Ejemplo n.º 14
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()
Ejemplo n.º 15
0
    def draw(self, ar):
        self.type_check()
        self.tic_interval = self.tic_interval or ar.y_grid_interval
        x_base = ar.loc[0] + self.offset

        canvas.line(self.line_style, x_base, ar.loc[1], x_base,
                    ar.loc[1] + ar.size[1])

        xmin = x_base + ar.size[0]  # somebigvalue
        tic_dic = {}
        for i in ar.y_tic_points(self.tic_interval):
            y_tic = ar.y_pos(i)
            tic_dic[i] = 1
            canvas.line(self.line_style, x_base, y_tic, x_base - self.tic_len,
                        y_tic)
            tic_label = pychart_util.apply_format(self.format, (i, ), 0)
            x = x_base - self.tic_len + self.tic_label_offset[0]
            if self.tic_len > 0:
                tic_label = "/hR" + tic_label

            tic_height, base_height = font.text_height(tic_label)
            canvas.show(x, y_tic - tic_height / 2.0 + self.tic_label_offset[1],
                        tic_label)
            xmin = min(xmin, x - font.text_width(tic_label))
        if self.minor_tic_interval:
            for i in ar.y_tic_points(self.minor_tic_interval):
                if tic_dic.has_key(i):
                    # a major tic was drawn already.
                    pass
                else:
                    y_tic = ar.y_pos(i)
                    canvas.line(self.line_style, x_base, y_tic,
                                x_base - self.minor_tic_len, y_tic)

        if self.label != None:
            xlabel = xmin - theme.default_font_size / 2.0
            ylabel = ar.loc[1] + ar.size[1] / 2
            if self.label_offset[0] != None:
                xlabel = xlabel + self.label_offset[0]
            if self.label_offset[1] != None:
                ylabel = ylabel + self.label_offset[1]
            canvas.show(xlabel, ylabel, "/a90/hC" + self.label)
Ejemplo n.º 16
0
   def draw(self, ar):
      self.type_check()
      self.tic_interval = self.tic_interval or ar.y_grid_interval
      x_base = ar.loc[0] + self.offset

      canvas.line(self.line_style, x_base, ar.loc[1],
                  x_base, ar.loc[1]+ar.size[1])
      
      xmin = x_base + ar.size[0] # somebigvalue
      tic_dic = {}
      for i in ar.y_tic_points(self.tic_interval):
         y_tic = ar.y_pos(i)
         tic_dic[i] = 1
         canvas.line(self.line_style, x_base, y_tic,
                     x_base - self.tic_len, y_tic)
         tic_label = pychart_util.apply_format(self.format, (i,), 0)
         x = x_base - self.tic_len + self.tic_label_offset[0]
         if self.tic_len > 0:
            tic_label = "/hR" + tic_label
            
         tic_height, base_height = font.text_height(tic_label)
         canvas.show(x, y_tic - tic_height/2.0 + self.tic_label_offset[1],
		     tic_label)
         xmin = min(xmin, x - font.text_width(tic_label))
      if self.minor_tic_interval:
         for i in ar.y_tic_points(self.minor_tic_interval):
            if tic_dic.has_key(i):
               # a major tic was drawn already.
               pass
            else:
               y_tic = ar.y_pos(i)
               canvas.line(self.line_style, x_base, y_tic,
                           x_base - self.minor_tic_len, y_tic)
               
      if self.label != None:
         xlabel = xmin - theme.default_font_size/2.0
         ylabel = ar.loc[1] + ar.size[1] / 2
         if self.label_offset[0] != None:
            xlabel = xlabel + self.label_offset[0]
         if self.label_offset[1] != None:
            ylabel = ylabel + self.label_offset[1]
         canvas.show(xlabel, ylabel, "/a90/hC" + self.label)
Ejemplo n.º 17
0
    def draw_vertical(self, ar, can):
        for pair in self.data:
            xval = pair[self.bcol]
            yval = pychart_util.get_sample_val(pair, self.hcol)

            if None in (xval, yval): continue

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

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

            can.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]
                if None not in (plus, minus, qplus, qminus):
                    self.error_bar.draw(
                        can, (thisX + self.width / 2.0, ar.y_pos(yval)),
                        ar.y_pos(yval - minus), ar.y_pos(yval + plus),
                        ar.y_pos(yval - qminus), ar.y_pos(yval + qplus))

            if self.data_label_format:
                can.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))
Ejemplo n.º 18
0
    def draw_vertical(self, ar, can):
        for pair in self.data:
            xval = pair[self.bcol]
            yval = pychart_util.get_sample_val(pair, self.hcol)
            
            if None in (xval, yval): continue

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

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

            can.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]
                if None not in (plus, minus, qplus, qminus): 
                    self.error_bar.draw(can, (thisX+self.width/2.0, ar.y_pos(yval)),
                                        ar.y_pos(yval - minus),
                                        ar.y_pos(yval + plus),
                                        ar.y_pos(yval - qminus),
                                        ar.y_pos(yval + qplus))
                    
            if self.data_label_format:
                can.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))
Ejemplo n.º 19
0
    def draw_horizontal(self, ar, can):
        for pair in self.data:
            yval = pair[self.bcol]
            xval = pychart_util.get_sample_val(pair, self.hcol)

            if None in (xval, yval): continue

            xbot = 0
            if self.stack_on:
                xbot = self.stack_on.get_value(yval)
                xval += xbot
            totalWidth = self.get_bar_width(ar, self.cluster[1])
            firstY = ar.y_pos(yval) - totalWidth/2.0
            thisY = firstY + self.get_bar_width(ar, self.cluster[0])
            
            can.rectangle(self.line_style, self.fill_style,
                          ar.x_pos(xbot), thisY,
                          ar.x_pos(xval), thisY+self.width)

            if self.data_label_format:
                can.show(ar.x_pos(xval) + self.data_label_offset[0],
		            thisY + self.width/2.0 + self.data_label_offset[1],
                            "/vM/hL" + pychart_util.apply_format(self.data_label_format, (pair[self.bcol], pair[self.hcol]), 1))
Ejemplo n.º 20
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))
Ejemplo n.º 21
0
    def draw(self, ar):
        self.type_check()
        self.tic_interval = self.tic_interval or ar.x_grid_interval
        y_base = ar.loc[1] + self.offset

        canvas.line(self.line_style, ar.loc[0], y_base, ar.loc[0] + ar.size[0],
                    y_base)

        tic_dic = {}
        max_tic_height = 0

        for i in ar.x_tic_points(self.tic_interval):
            tic_dic[i] = 1
            ticx = ar.x_pos(i)

            str = "/hC" + pychart_util.apply_format(self.format, (i, ), 0)

            (total_height, base_height) = font.text_height(str)
            max_tic_height = max(max_tic_height, total_height)

            canvas.line(self.line_style, ticx, y_base, ticx,
                        y_base - self.tic_len)
            canvas.show(
                ticx + self.tic_label_offset[0],
                y_base - self.tic_len - base_height + self.tic_label_offset[1],
                str)

        if self.minor_tic_interval:
            for i in ar.x_tic_points(self.minor_tic_interval):
                if tic_dic.has_key(i):
                    # a major tic was drawn already.
                    pass
                else:
                    ticx = ar.x_pos(i)
                    canvas.line(self.line_style, ticx, y_base, ticx,
                                y_base - self.minor_tic_len)

        if self.label != None:
            str = "/hC/vM" + self.label
            (label_height, base_height) = font.text_height(str)
            xlabel = ar.loc[0] + ar.size[0] / 2.0
            ylabel = y_base - self.tic_len - max_tic_height - 10
            if self.label_offset[0] != None:
                xlabel = xlabel + self.label_offset[0]
            if self.label_offset[1] != None:
                ylabel = ylabel + self.label_offset[1]
            canvas.show(xlabel, ylabel, str)

        tic_dic = {}
        max_tic_height = 0

        for i in ar.x_tic_points(self.tic_interval):
            tic_dic[i] = 1
            ticx = ar.x_pos(i)

            str = "/hC" + pychart_util.apply_format(self.format, (i, ), 0)

            (total_height, base_height) = font.text_height(str)
            max_tic_height = max(max_tic_height, total_height)

            canvas.line(self.line_style, ticx, y_base, ticx,
                        y_base - self.tic_len)
            canvas.show(
                ticx + self.tic_label_offset[0],
                y_base - self.tic_len - base_height + self.tic_label_offset[1],
                str)

        if self.minor_tic_interval:
            for i in ar.x_tic_points(self.minor_tic_interval):
                if tic_dic.has_key(i):
                    # a major tic was drawn already.
                    pass
                else:
                    ticx = ar.x_pos(i)
                    canvas.line(self.line_style, ticx, y_base, ticx,
                                y_base - self.minor_tic_len)

        if self.label != None:
            str = "/hC/vM" + self.label
            (label_height, base_height) = font.text_height(str)
            if self.label_offset[0] != None:
                xlabel = ar.loc[0] + self.label_offset[0]
            else:
                xlabel = ar.loc[0] + ar.size[0] / 2.0
            if self.label_offset[1] != None:
                ylabel = y_base + self.label_offset[1]
            else:
                ylabel = y_base - self.tic_len - max_tic_height - 10
            canvas.show(xlabel, ylabel, str)
Ejemplo n.º 22
0
    def draw(self, ar):
        self.type_check()
        self.tic_interval = self.tic_interval or ar.x_grid_interval
        y_base = ar.loc[1] + self.offset
      
        canvas.line(self.line_style, ar.loc[0], y_base,
                    ar.loc[0]+ ar.size[0], y_base)

        tic_dic = {}
        max_tic_height = 0
      
        for i in ar.x_tic_points(self.tic_interval):
            tic_dic[i] = 1
            ticx = ar.x_pos(i)

            str = "/hC" + pychart_util.apply_format(self.format, (i, ), 0)

            (total_height, base_height) = font.text_height(str)
            max_tic_height = max(max_tic_height, total_height)

            canvas.line(self.line_style, ticx, y_base, ticx, y_base-self.tic_len)
            canvas.show(ticx+self.tic_label_offset[0], 
                        y_base-self.tic_len-base_height+self.tic_label_offset[1],
                        str)
         
        if self.minor_tic_interval:
            for i in ar.x_tic_points(self.minor_tic_interval):
                if tic_dic.has_key(i):
                    # a major tic was drawn already.
                    pass
                else:
                    ticx = ar.x_pos(i)
                    canvas.line(self.line_style, ticx, y_base, ticx,
                                y_base-self.minor_tic_len)

        if self.label != None:
            str = "/hC/vM" + self.label
            (label_height, base_height) = font.text_height(str)
            xlabel = ar.loc[0] + ar.size[0]/2.0
            ylabel = y_base - self.tic_len - max_tic_height - 10
            if self.label_offset[0] != None:
                xlabel = xlabel + self.label_offset[0]
            if self.label_offset[1] != None:
                ylabel = ylabel + self.label_offset[1]
            canvas.show(xlabel, ylabel, str)

        tic_dic = {}
        max_tic_height = 0

        for i in ar.x_tic_points(self.tic_interval):
            tic_dic[i] = 1
            ticx = ar.x_pos(i)

            str = "/hC" + pychart_util.apply_format(self.format, (i,), 0)

            (total_height, base_height) = font.text_height(str)
            max_tic_height = max(max_tic_height, total_height)

            canvas.line(self.line_style, ticx, y_base, ticx, y_base-self.tic_len)
            canvas.show(ticx+self.tic_label_offset[0], 
                        y_base-self.tic_len-base_height+self.tic_label_offset[1],
                        str)

        if self.minor_tic_interval:
            for i in ar.x_tic_points(self.minor_tic_interval):
                if tic_dic.has_key(i):
                    # a major tic was drawn already.
                    pass
                else:
                    ticx = ar.x_pos(i)
                    canvas.line(self.line_style, ticx, y_base, ticx,
                                y_base-self.minor_tic_len)

        if self.label != None:
            str = "/hC/vM" + self.label
            (label_height, base_height) = font.text_height(str)
            if self.label_offset[0] != None:
                xlabel = ar.loc[0] + self.label_offset[0]
            else:
                xlabel = ar.loc[0] + ar.size[0]/2.0
            if self.label_offset[1] != None:
                ylabel = y_base + self.label_offset[1]
            else:
                ylabel = y_base - self.tic_len - max_tic_height - 10
            canvas.show(xlabel, ylabel, str)