Beispiel #1
0
    def __draw_y_axis_for_time_value(self, axis, axis_position, reverse):
        start_point = Point(axis_position, self.top_margin + self.height)
        end_point = Point(axis_position, self.top_margin)
        self.svg_contents += svg_monkey.write_line(start_point, end_point,
                                                   'Black', 'axis')

        if axis.markers != None:
            for counter in range(0, len(axis.markers)):
                start_point = Point(
                    axis_position, (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))
                end_point = Point(
                    self.__handle_reverse(reverse, axis_position, 15),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))
                self.svg_contents += svg_monkey.write_line(
                    start_point, end_point, 'Black', 'axis')

                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str(axis.markers[counter].marker.label), 0,
                    'y_axis_label')
        self.__draw_y_axis_title(axis, 150)
Beispiel #2
0
    def __draw_y_axis_for_int(self, axis, axis_position, reverse):
        start_point = Point(axis_position, self.top_margin + self.height)
        end_point = Point(axis_position, self.top_margin)
        self.svg_contents += svg_monkey.write_line(start_point, end_point,
                                                   'Black', 'axis')

        #REFACTOR AHOY!!
        css_label = 'y_axis_label'
        if reverse == True:
            css_label = css_label + '_reverse'

        if axis.markers != None:
            for counter in range(0, len(axis.markers)):  #-1
                start_point = Point(
                    axis_position, (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))
                end_point = Point(
                    self.__handle_reverse(reverse, axis_position, 15),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))

                #print(axis.markers[counter].marker.label,axis.markers[counter].percentile, start_point.x, start_point.y)

                self.svg_contents += svg_monkey.write_line(
                    start_point, end_point, 'Black', 'axis')

                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str((axis.markers[counter].marker.label)), 0,
                    css_label)
        self.__draw_y_axis_title(axis)
Beispiel #3
0
    def __build_legend_contents(self, left, primary_colours_palete,
                                secondary_colours_palete):
        contents = ''

        #colours_palete = ColoursPalete(3)
        spacer = 20
        #left = self.left_margin + self.width + 50
        if self.additional_axis_meta_data is not None:
            left += 50
        #this is now handled with a separate method call (title and legend now different)
        #contents += svg_monkey.write_text(Point(left, self.top_margin), 'Legend', 0, 'legend_item_title')

        for data_set in self.data_sets:  #sorted(self.data_sets):
            if data_set.axis_type == AxisType.PRIMARY:
                colours_palete = primary_colours_palete
            else:
                colours_palete = secondary_colours_palete

            colour = colours_palete.get_next_colour()
            contents += svg_monkey.write_line(Point(left - 30, spacer - 3),
                                              Point(left - 10, spacer - 3),
                                              colour, None, str(data_set.id))
            contents += svg_monkey.write_text(
                Point(left, spacer), data_set.name, 0, 'legend_item', colour,
                str(data_set.id),
                'onclick="highlight_lines(\'' + str(data_set.id) + '\');"')
            spacer += 20
        return contents
Beispiel #4
0
    def __draw_x_axis(self):
        start_point = Point(self.left_margin, self.top_margin + self.height)
        end_point = Point(self.left_margin + self.width,
                          self.top_margin + self.height)
        self.svg_contents += svg_monkey.write_line(start_point, end_point,
                                                   'Black', 'axis')

        rotated_labels = False
        if self.x_axis.markers != None:
            for counter in range(0, len(self.x_axis.markers) - 1):  #-1
                start_point = Point(
                    self.left_margin +
                    (self.x_axis.markers[counter].percentile * self.width),
                    self.top_margin + self.height)
                end_point = Point(
                    self.left_margin +
                    (self.x_axis.markers[counter].percentile * self.width),
                    self.top_margin + self.height + 15)
                self.svg_contents += svg_monkey.write_line(
                    start_point, end_point, 'Black', 'axis')

                start_point = Point(
                    self.left_margin + 5 +
                    (self.x_axis.markers[counter].percentile * self.width),
                    self.top_margin + self.height + 30)
                rotation = 0
                y_position = self.top_margin + self.height + 30
                if str(self.x_axis.markers[counter].marker.label).find(
                        ' ') > -1:
                    if rotated_labels == False:
                        rotated_labels = True
                    rotation = 90
                    y_position = y_position + 45

                self.svg_contents += svg_monkey.write_text(
                    start_point,
                    str(self.x_axis.markers[counter].marker.label), rotation,
                    'x_axis_label')

        self.__draw_x_axis_title(rotated_labels)
Beispiel #5
0
    def __draw_y_axis_for_float(self, axis, axis_position, reverse):
        # print(axis.low, axis.high)
        # print(len(axis.markers))
        start_point = Point(axis_position, self.top_margin + self.height)
        end_point = Point(axis_position, self.top_margin)
        self.svg_contents += svg_monkey.write_line(start_point, end_point,
                                                   'Black', 'axis')

        #refactor AHOY!
        css_label = 'y_axis_label'
        if reverse == True:
            css_label = css_label + '_reverse'

        if axis.markers != None:
            for counter in range(0, len(axis.markers)):  #-1
                start_point = Point(
                    axis_position, (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))
                end_point = Point(
                    self.__handle_reverse(reverse, axis_position, 15),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))

                # print(str(start_point.x) + ',' +  str(start_point.y) + ',' + str(axis.markers[counter].percentile) + ',"' + str(axis.markers[counter].marker.value) + '"')

                self.svg_contents += svg_monkey.write_line(
                    start_point, end_point, 'Black', 'axis')

                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str(axis.markers[counter].marker.label), 0,
                    css_label)
        self.__draw_y_axis_title(axis, 150)
Beispiel #6
0
    def __new_draw_y_axis(self, axis, axis_position, reverse):

        start_point = Point(axis_position, self.top_margin + self.height)
        end_point = Point(axis_position, self.top_margin)
        self.svg_contents += svg_monkey.write_line(start_point, end_point,
                                                   'Black', 'axis')

        #REFACTOR AHOY!!
        css_label = 'y_axis_label'
        if reverse == True:
            css_label = css_label + '_reverse'

        if axis.markers != None:
            for counter in range(0, len(axis.markers) - 1):
                start_point = Point(
                    axis_position, (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))
                end_point = Point(
                    self.__handle_reverse(reverse, axis_position, 15),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height))

                self.svg_contents += svg_monkey.write_line(
                    start_point, end_point, 'Black', 'axis')

                #int
                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str((axis.markers[counter].marker.label)), 0,
                    css_label)

                #date
                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 65),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point,
                    self.__format_axis_label_for_date(
                        axis.markers[counter].marker.value,
                        self.x_axis_format), 0, 'y_axis_label')

                #datetime
                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 65),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str(axis.markers[counter].marker.label), 0,
                    'y_axis_label')

                #timevalue
                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str(axis.markers[counter].marker.label), 0,
                    'y_axis_label')

                #float
                label_point = Point(
                    self.__handle_reverse(reverse, axis_position, 20),
                    (self.top_margin + self.height) -
                    (axis.markers[counter].percentile * self.height) + 5)
                self.svg_contents += svg_monkey.write_text(
                    label_point, str(axis.markers[counter].marker.label), 0,
                    css_label)

        self.__draw_y_axis_title(axis)