Exemplo n.º 1
0
    def passenger_graph(self, event_id):
        # data = self.demand(event_id)
        barchart = bar_chart.BarChart()

        barchart.title.set_text(
            'Estimated number of passengers upcoming hours')
        barchart.grid.set_visible(True)
        barchart.grid.set_line_style(pygtk_chart.LINE_STYLE_DOTTED)
        barchart.set_mode(bar_chart.MODE_HORIZONTAL)
        rospy.logwarn(self.demand)

        for bar_info in self.demand:
            bar_info = list(bar_info)
            bar = bar_chart.Bar(bar_info[0], bar_info[1], bar_info[2])
            bar.set_color(standardgray)
            barchart.add_bar(bar)
            barchart.queue_draw()

        for widget in self.hbox_graph.get_children():
            self.hbox_graph.remove(widget)

        self.hbox_graph.pack_start(barchart)

        def cb_bar_clicked(barchart, bar):
            print "Bar '%s' clicked." % bar.get_label()

        barchart.connect("bar-clicked", cb_bar_clicked)

        barchart.show()
Exemplo n.º 2
0
    def stat_graph(self, event_id):
        data = self.stats(event_id)

        statchart = bar_chart.BarChart()

        statchart.title.set_text('Impact of dynamic routing')
        statchart.grid.set_visible(True)
        statchart.grid.set_line_style(pygtk_chart.LINE_STYLE_DOTTED)
        statchart.set_mode(bar_chart.MODE_VERTICAL)

        for bar_info in data:
            bar = bar_chart.Bar(*bar_info)
            if bar_info[1] <= 100:
                bar.set_color(green)
            elif bar_info[1] > 100:
                bar.set_color(red)
            statchart.add_bar(bar)
            #statchart.queue_draw()

        self.hbox_graph.pack_start(statchart, True, True, 0)

        #width, height = 400, 300
        #box.set_size_request(width, height)

        def cb_bar_clicked(statchart, bar):
            print "Bar '%s' clicked." % bar.get_label()

        statchart.connect("bar-clicked", cb_bar_clicked)
        statchart.show()
Exemplo n.º 3
0
    def calculate(self, widget):

        combobox = self.builder.get_object("eventbox1").get_child()
        model = combobox.get_model()

        taxon = combobox.get_child().get_text()

        if self.builder.get_object("viewport1").get_child():
            self.builder.get_object("viewport1").get_child().destroy()

        if taxon.lower() in self.taxa:
            chart = bar_chart.BarChart()

            total_rec = 0

            for month in [
                    "Jan",
                    "Feb",
                    "Mar",
                    "Apr",
                    "May",
                    "Jun",
                    "Jul",
                    "Aug",
                    "Sep",
                    "Oct",
                    "Nov",
                    "Dec",
            ]:
                bar = bar_chart.Bar(month, self.taxa[taxon.lower()][month],
                                    month)
                chart.add_bar(bar)
                total_rec = total_rec + self.taxa[taxon.lower()][month]

            if total_rec == 1:
                s_ = ''
            else:
                s_ = 's'

            chart.title.set_text(''.join([
                'Temporal distribution of ', taxon, ' (',
                str(total_rec), ' record', s_, ')'
            ]))

            self.builder.get_object("viewport1").add(chart)
            chart.show()
Exemplo n.º 4
0
def barchart(app, title, data):
    barchart = bar_chart.BarChart()
    #	barchart.title.set_text(title)
    barchart.grid.set_visible(True)
    barchart.grid.set_line_style(pygtk_chart.LINE_STYLE_DOTTED)
    barchart.set_mode(bar_chart.MODE_HORIZONTAL)

    for bar_info in data:
        bar = bar_chart.Bar(*bar_info)
        #bar.set_corner_radius(4)
        barchart.add_bar(bar)

    window = gtk.Window()
    window.set_title(title + " - " + app)
    window.add(barchart)
    window.resize(800, 400)
    window.show_all()
Exemplo n.º 5
0
import gtk
import pygtk

import pygtk_chart
from pygtk_chart import bar_chart

data = [
    ('wheat', 276, 'Wheat'),
    ('oat', 52, 'Oat'),
    ('white', 652, 'White'),
    ('sour', 65, 'Sourdough'),
    ('raisin', 120, 'Raisin'),
]

barchart = bar_chart.BarChart()
barchart.title.set_text('Loaves of Bread Made')
barchart.grid.set_visible(True)
barchart.grid.set_line_style(pygtk_chart.LINE_STYLE_DOTTED)
barchart.set_mode(bar_chart.MODE_HORIZONTAL)

for bar_info in data:
    bar = bar_chart.Bar(*bar_info)
    #bar.set_corner_radius(4)
    barchart.add_bar(bar)


def cb_bar_clicked(barchart, bar):
    print "Bar '%s' clicked." % bar.get_label()


barchart.connect("bar-clicked", cb_bar_clicked)