예제 #1
0
파일: stat.py 프로젝트: ssorj/boneyard
    def create(self, session, adapter, stats):
        names = self.page.names.get(session)
        values = self.page.values.get(session)
        nvs = dict()
        for name, value in zip(names, values):
            nvs[name] = value

        # move Unclaimed to end of list
        sorted_names = sorted(names)
        sorted_names.remove("Unclaimed")
        sorted_names.append("Unclaimed")

        chart = Chart()
        chart.title.text = ""
        chart.bg_colour = "#FFFFFF"

        chart.elements = list()
        element = Element()
        element.type = "pie"
        element.alpha = 7
        element.start_angle = 0
        element.gradient_fill = True
        element.radius = 90

        element.animate = list()
        animation = Element()
        animation.type = "fade"
        element.animate.append(animation)
        animation = Element()
        animation.type = "bounce"
        animation.distance = 8
        element.animate.append(animation)
        element.tip = "#percent#"

        element.colours = []
        for i in range(len(sorted_names)):
            j = i % len(self.colors)
            if sorted_names[i] == "Unclaimed":
                color = "#EEEEEE"
            else:
                color = self.colors[j]
            element.colours.append(color)
        element.colours.append("#EEEEEE")

        element.on_click = "ofc_change_priority"
        id = self.page.chart_id.get(session)
        element.on_click_text = "#percent#|#val#|#label#|%s" % id

        element.values = [{"label": x, "value": float(nvs[x])} for x in sorted_names]

        chart.elements.append(element)
        return chart.create()
예제 #2
0
파일: stat.py 프로젝트: ssorj/boneyard
    def get_chart(self, session, adapter, stats, samples, duration, max_value, min_value, append, end_secs):
        mode = self.page.mode.get(session)

        width = self.page.container_width.get(session)
        dot_size = 1
        halo_size = 0
        line_width = 0
        if width > 400:
            dot_size = 3
            halo_size = 1

        chart = Chart()
        id = self.page.chart_id.get(session)
        if isinstance(id, unicode):
            id = id.encode('ascii', 'replace')
        chart.id = id
        chart.bg_colour = "#FFFFFF"
        chart.tnow =  time()
        chart.duration = duration
        chart.end_secs = end_secs

        self.make_chart_lines(session, chart, "area", stats, dot_size, halo_size, line_width, samples, duration, end_secs, mode)

        if append:
            chart.append = self.get_elapsed(session)['value']
            return chart

        chart.title.text = ""
        chart.title.style = "{text-align: left; font-weight: bold; font-size: 14px;}"
        chart.tooltip = {"colour": "#000033",
                         "background": "#FFFFCC",
                         "stroke": 1,
                         "title": "{background-color: #000022; color: #FFFFFF; font-size: 1em;}",
                         "body": "{font-size: 10px; color: #000000;}"
                         }

        chart.x_axis = XAxis().get_x_axis(duration, end_secs)
        y_axis, y_axis_right = self.get_y_axis(max_value, min_value)
        chart.y_axis = y_axis
        chart.y_axis_right = y_axis_right

        # if we are big enough, add a control slider to pan and zoom
        if width > 400:
            chart.control.bg_colour = "#DDDDDD"
            chart.control.x_axis = XAxis().get_x_axis(self.one_day, 0, tick_height=10)
            chart.control.x_axis.labels.colour = "#333333"
            chart.control.x_axis.grid_colour = "#FFFFFF"
            samples = self.fetch_samples(adapter, self.one_day, 180, "avg", mode, False, stats, end_seconds_ago=0)
            self.add_control_points(session, stats, samples)
            max_value, min_value = self.get_max_min(session, stats, samples)
            self.make_chart_lines(session, chart.control, "area", stats, 1, 0, 0, samples, self.one_day, 0, mode)
            chart.control.y_min = max(min_value, 0)
            chart.control.y_max = max(max_value-2, 1)
            chart.control.slider_low.value = float(self.page.control_min.get(session))
            chart.control.slider_low.colour = "#666666"
            chart.control.slider_high.value = float(self.page.control_max.get(session))
            chart.control.slider_high.colour = "#666666"
            chart.control.tnow =  time()
            chart.control.duration = self.one_day
            chart.control.end_secs = 0

        #print "sending entire sample set with y_axis.max=%i" % chart.y_axis["max"]
        return chart