Beispiel #1
0
class MainWindow:
    def __init__(self):
        # create widget tree ...
        xml = gtk.glade.XML('test.glade')

        # connect handlers
        xml.signal_autoconnect(self)

        # widgets
        self.main_window = xml.get_widget('main_window')
        self.hbox_graph = xml.get_widget('hbox_graph')
        
        # add graph
        self.graph = CaGraph()
        self.hbox_graph.pack_start(self.graph)
        
        # create and add axiss to graph
        xaxis = CaGraphXAxis(self.graph)
        yaxis = CaGraphYAxis(self.graph)
        
        self.graph.axiss.append(xaxis)
        self.graph.axiss.append(yaxis)
        
        # create and add series to graph
        self.graph.seriess.append(CaGraphSeriesArea(self.graph, 0, 1))
        self.graph.seriess.append(CaGraphSeriesBar(self.graph, 0, 1))
        
        # add data
        self.graph.seriess[0].data = [
            (10.0,52.0),(20.0,70.0),
            (30.0,53.0),(40.0,38),
            (50.0,75.0), (60.0,85.0),
            (70.0,65.0)]
        
        self.graph.seriess[1].data = [
            (10.0,42.0),(20.0,50.0),
            (30.0,63.0),(40.0,68),
            (50.0,75.0), (60.0,95.0),
            (70.0,65.0)]
        
        # automaticaly set axis ranges
        self.graph.auto_set_range()
        
        # add grid
        self.graph.grid = CaGraphGrid(self.graph, 0, 1)
        
        # set yaxis to include zero
        yaxis.min = 0
        
        # show wigdet
        self.graph.show()
    
        # draw to file
        self.graph.draw_to_file('example2.svg')
        self.graph.draw_to_file('example2.png')
        
    # signal handlers
    def on_main_window_delete_event(self, widget, obj):
        "on_main_window_delete_event activated"
        gtk.main_quit()
Beispiel #2
0
class MainWindow:
    def __init__(self):
        # create widget tree ...
        xml = gtk.glade.XML('test.glade')

        # connect handlers
        xml.signal_autoconnect(self)

        # widgets
        self.main_window = xml.get_widget('main_window')
        self.hbox_graph = xml.get_widget('hbox_graph')

        # add graph
        self.graph = CaGraph()
        self.hbox_graph.pack_start(self.graph)

        # create and add axiss to graph
        xaxis = CaGraphXAxis(self.graph)
        yaxis = CaGraphYAxis(self.graph)
        self.graph.axiss.append(xaxis)
        self.graph.axiss.append(yaxis)

        # create and add series to graph
        self.graph.seriess.append(CaGraphSeriesLine(self.graph, 0, 1))
        self.graph.seriess.append(CaGraphSeriesHBar(self.graph, 0, 1))
        self.graph.seriess.append(CaGraphSeriesLabels(self.graph, 0, 1))

        # add data to seriess
        # add data to seriess
        self.graph.seriess[0].data = [(52.0, 10.0), (70.0, 20.0), (53.0, 30.0),
                                      (38, 40.0), (75.0, 50.0), (85.0, 60.0),
                                      (65.0, 70.0)]

        self.graph.seriess[1].data = [(32.0, 10.0), (10.0, 20.0), (33.0, 30.0),
                                      (38, 40.0), (55.0, 50.0), (65.0, 60.0),
                                      (75.0, 70.0)]

        self.graph.seriess[2].data = [(32.0, 10.0, u'point 1'),
                                      (10.0, 20.0, u'point 2'),
                                      (33.0, 30.0, u'point 3'),
                                      (38, 40.0, u'point 4'),
                                      (55.0, 50.0, u'point 5'),
                                      (65.0, 60.0, u'point 6'),
                                      (75.0, 70.0, u'point 7')]

        # add labels

        # automaticaly set axis ranges
        self.graph.auto_set_range()

        # show wigdet
        self.graph.show()

        # draw to file
        self.graph.draw_to_file('example8.svg')
        self.graph.draw_to_file('example8.png')

    def on_main_window_delete_event(self, widget, obj):
        "on_main_window_delete_event activated"
        gtk.main_quit()
Beispiel #3
0
class MainWindow:
    def __init__(self):
        # create widget tree ...
        xml = gtk.glade.XML('test.glade')

        # connect handlers
        xml.signal_autoconnect(self)

        # widgets
        self.main_window = xml.get_widget('main_window')
        self.hbox_graph = xml.get_widget('hbox_graph')
        
        # add graph
        self.graph = CaGraph()
        self.hbox_graph.pack_start(self.graph)
        
        # create and add axiss to graph
        xaxis = CaGraphXAxis(self.graph)
        yaxis = CaGraphYAxis(self.graph)
        self.graph.axiss.append(xaxis)
        self.graph.axiss.append(yaxis)
                
        # create and add series to graph
        self.graph.seriess.append(CaGraphSeriesLine(self.graph, 0, 1))
        self.graph.seriess.append(CaGraphSeriesHBar(self.graph, 0, 1))
        
        # add data to seriess
        self.graph.seriess[0].data = [
            (52.0,10.0),(70.0,20.0),
            (53.0,30.0),(38,40.0),
            (75.0,50.0), (85.0,60.0),
            (65.0,70.0)]
        
        self.graph.seriess[1].data = [
            (32.0,10.0),(10.0,20.0),
            (33.0,30.0),(38,40.0),
            (55.0,50.0), (65.0,60.0),
            (75.0,70.0)]
        
        # automaticaly set axis ranges
        self.graph.auto_set_range()
        
        # show wigdet
        self.graph.show()
    
        # draw to file
        self.graph.draw_to_file('example9.svg')
        self.graph.draw_to_file('example9.png')
    
    def on_main_window_delete_event(self, widget, obj):
        "on_main_window_delete_event activated"
        gtk.main_quit()
Beispiel #4
0
class MainWindow:
    def __init__(self):
        # create widget tree ...
        xml = gtk.glade.XML("test.glade")

        # connect handlers
        xml.signal_autoconnect(self)

        # widgets
        self.main_window = xml.get_widget("main_window")
        self.hbox_graph = xml.get_widget("hbox_graph")

        # add graph
        self.graph = CaGraph()
        self.hbox_graph.pack_start(self.graph)

        # add axiss to graph
        self.graph.axiss.append(CaGraphTAxis(self.graph))
        self.graph.axiss.append(CaGraphYAxis(self.graph))

        # top axis
        top_axis = CaGraphXAxis(self.graph)
        top_axis.axis_style.side = "top"
        top_axis.axis_style.draw_labels = False
        self.graph.axiss.append(top_axis)

        # right axis
        right_axis = CaGraphYAxis(self.graph)
        right_axis.axis_style.side = "right"
        right_axis.axis_style.draw_labels = False
        self.graph.axiss.append(right_axis)

        # add series to graph
        self.graph.seriess.append(CaGraphSeriesLine(self.graph, 0, 1))
        self.graph.seriess.append(CaGraphSeriesBar(self.graph, 0, 1))
        self.graph.seriess.append(CaGraphSeriesArea(self.graph, 0, 1))

        # add data
        self.graph.seriess[0].data = [
            (-10.0, -12.0),
            (0.0, 12.0),
            (10.0, 23.0),
            (20.0, 18),
            (30.0, -5.0),
            (40.0, -15.0),
            (50.0, 15.0),
        ]

        self.graph.seriess[1].data = [
            (-14.0, -1.0),
            (0.0, 2.0),
            (10.0, 33.0),
            (20.0, 8),
            (30.0, -1.0),
            (40.0, -1.0),
            (50.0, 19.0),
        ]

        self.graph.seriess[2].data = [
            (-10.0, -10.0),
            (0.0, 8.0),
            (10.0, 23.0),
            (20.0, 14.0),
            (30.0, -2.0),
            (40.0, -3.0),
            (50.0, 8.0),
        ]

        # set axis ranges
        self.graph.auto_set_range()

        # add grid
        self.graph.grid = CaGraphGrid(self.graph, 0, 1)

        self.graph.show()

        # draw to file
        self.graph.draw_to_file("test.svg", 600, 600)

    # signal handlers
    def on_main_window_delete_event(self, widget, obj):
        "on_main_window_delete_event activated"
        gtk.main_quit()
Beispiel #5
0
class MainWindow:
    def __init__(self):
        # create widget tree ...
        xml = gtk.glade.XML('test.glade')

        # connect handlers
        xml.signal_autoconnect(self)

        # widgets
        self.main_window = xml.get_widget('main_window')
        self.hbox_graph = xml.get_widget('hbox_graph')
        
        # add graph
        self.graph = CaGraph()
        self.hbox_graph.pack_start(self.graph)
        
        # create and add axiss to graph
        xaxis = CaGraphXAxis(self.graph)
        yaxis = CaGraphYAxis(self.graph)
        self.graph.axiss.append(xaxis)
        self.graph.axiss.append(yaxis)
        
        # create and add top axis
        top_axis = CaGraphXAxis(self.graph)
        top_axis.axis_style.side = 'top'
        top_axis.axis_style.draw_labels = False
        self.graph.axiss.append(top_axis)
        
        # create and add right axis
        right_axis = CaGraphYAxis(self.graph)
        right_axis.axis_style.side = 'right'
        right_axis.axis_style.draw_labels = False
        self.graph.axiss.append(right_axis)
        
        # create and add series to graph
        series1 = CaGraphSeriesLine(self.graph, 0, 1)
        series2 = CaGraphSeriesArea(self.graph, 0, 1)
        series3 = CaGraphSeriesLine(self.graph, 0, 1)
        
        self.graph.seriess.append(series2)
        self.graph.seriess.append(series3)
        self.graph.seriess.append(series1)
        
        # set line style
        series1.style.line_color = (1.0, 0.0, 0.0, 1.0)
        series1.style.line_width = 2.0
        series1.style.point_type = ''
        
        series2.style.line_color = (0.0, 1.0, 0.0, 1.0)
        series2.style.fill_color = (0.0, 1.0, 0.0, 0.3)
        series2.style.line_width = 2.0
        series2.style.point_type = ''
        
        series3.style.line_color = (0.0, 0.6, 0.0, 1.0)
        series3.style.line_width = 0.0
        series3.style.point_type = 'o'
        
        # add data to seriess
        for i in range(-360, 720):
            alpha = math.pi * i / 180.0
            
            series1.data.append( (alpha, math.sin(alpha)) )
            series2.data.append( (alpha, math.cos(alpha)) )
        
        for i in range(-360, 720, 20):
            alpha = math.pi * i / 180.0
            
            series3.data.append( (alpha, math.cos(alpha)) )
            
        # automaticaly set axis ranges
        self.graph.auto_set_range()
        
        # add grid
        self.graph.grid = CaGraphGrid(self.graph, 0, 1)
        
        # show wigdet
        self.graph.show()
    
        # draw to file
        self.graph.draw_to_file('example3.svg', 700, 300)
        self.graph.draw_to_file('example3.png', 700, 300)
        
    # signal handlers
    def on_main_window_delete_event(self, widget, obj):
        "on_main_window_delete_event activated"
        gtk.main_quit()
Beispiel #6
0
class MainWindow:
    def __init__(self):
        # create widget tree ...
        xml = gtk.glade.XML('test.glade')

        # connect handlers
        xml.signal_autoconnect(self)

        # widgets
        self.main_window = xml.get_widget('main_window')
        self.hbox_graph = xml.get_widget('hbox_graph')

        # add graph
        self.graph = CaGraph()
        self.hbox_graph.pack_start(self.graph)

        # create and add axiss to graph
        time_axis = CaGraphTAxis(self.graph)
        yaxis = CaGraphYAxis(self.graph)

        self.graph.axiss.append(time_axis)
        self.graph.axiss.append(yaxis)

        # create and add series to graph
        series1 = CaGraphSeriesBar(self.graph, 0, 1)
        series2 = CaGraphSeriesBar(self.graph, 0, 1)

        self.graph.seriess.append(series1)
        self.graph.seriess.append(series2)

        # set time axis style
        time_axis.axis_style.label_format = "%H:%M:%S"

        # set bar seriess style
        series1.style.line_color = (1.0, 0.0, 1.0, 1.0)
        series1.style.fill_color = (1.0, 0.0, 1.0, 0.3)

        series2.style.line_color = (0.0, 1.0, 0.0, 1.0)
        series2.style.fill_color = (0.0, 1.0, 0.0, 0.3)

        # add data
        series1.data = [(910.0, 52.0), (920.0, 70.0), (930.0, 53.0),
                        (940.0, 38), (950.0, 75.0), (960.0, 85.0),
                        (970.0, 65.0)]

        series2.data = [(915.0, 42.0), (925.0, 50.0), (935.0, 63.0),
                        (945.0, 68), (955.0, 75.0), (965.0, 95.0),
                        (975.0, 65.0)]

        # automaticaly set axis ranges
        self.graph.auto_set_range()

        # add grid
        self.graph.grid = CaGraphGrid(self.graph, 0, 1)

        # set yaxis to include zero
        yaxis.min = 0

        # show wigdet
        self.graph.show()

        # draw to file
        self.graph.draw_to_file('example4.svg')
        self.graph.draw_to_file('example4.png')

    # signal handlers
    def on_main_window_delete_event(self, widget, obj):
        "on_main_window_delete_event activated"
        gtk.main_quit()
Beispiel #7
0
class MainWindow:
    def __init__(self):
        # create widget tree ...
        xml = gtk.glade.XML('test.glade')

        # connect handlers
        xml.signal_autoconnect(self)

        # widgets
        self.main_window = xml.get_widget('main_window')
        self.hbox_graph = xml.get_widget('hbox_graph')
        
        # add graph
        self.graph = CaGraph()
        self.hbox_graph.pack_start(self.graph)
        
        # add axiss to graph
        self.graph.axiss.append(CaGraphTAxis(self.graph))
        self.graph.axiss.append(CaGraphYAxis(self.graph))
        
        # top axis
        top_axis = CaGraphXAxis(self.graph)
        top_axis.axis_style.side = 'top'
        top_axis.axis_style.draw_labels = False
        self.graph.axiss.append(top_axis)
        
        # right axis
        right_axis = CaGraphYAxis(self.graph)
        right_axis.axis_style.side = 'right'
        right_axis.axis_style.draw_labels = False
        self.graph.axiss.append(right_axis)
        
        # add series to graph
        self.graph.seriess.append(CaGraphSeriesLine(self.graph, 0, 1))
        self.graph.seriess.append(CaGraphSeriesBar(self.graph, 0, 1))
        self.graph.seriess.append(CaGraphSeriesArea(self.graph, 0, 1))
        
        # add data
        self.graph.seriess[0].data = [
            (-10.0,-12.0),(0.0,12.0),
            (10.0,23.0),(20.0,18),
            (30.0,-5.0), (40.0,-15.0),
            (50.0,15.0)]
        
        self.graph.seriess[1].data = [
            (-14.0,-1.0),(0.0,2.0),
            (10.0,33.0),(20.0,8),
            (30.0,-1.0), (40.0,-1.0),
            (50.0,19.0)]
        
        self.graph.seriess[2].data = [
            (-10.0,-10.0),(0.0,8.0),
            (10.0,23.0),(20.0,14.0),
            (30.0,-2.0), (40.0,-3.0),
            (50.0,8.0)]
        
        # set axis ranges
        self.graph.auto_set_range()
        
        # add grid
        self.graph.grid = CaGraphGrid(self.graph, 0, 1)
        
        self.graph.show()
    
        # draw to file
        self.graph.draw_to_file('test.svg', 600, 600)
        
    # signal handlers
    def on_main_window_delete_event(self, widget, obj):
        "on_main_window_delete_event activated"
        gtk.main_quit()
Beispiel #8
0
class MainWindow:
    def __init__(self):
        # create widget tree ...
        xml = gtk.glade.XML('test.glade')

        # connect handlers
        xml.signal_autoconnect(self)

        # widgets
        self.main_window = xml.get_widget('main_window')
        self.hbox_graph = xml.get_widget('hbox_graph')

        # add graph
        self.graph = CaGraph()
        self.hbox_graph.pack_start(self.graph)

        # create and add axiss to graph
        xaxis = CaGraphXAxis(self.graph)
        yaxis = CaGraphYAxis(self.graph)
        self.graph.axiss.append(xaxis)
        self.graph.axiss.append(yaxis)

        # create and add top axis
        top_axis = CaGraphXAxis(self.graph)
        top_axis.axis_style.side = 'top'
        top_axis.axis_style.draw_labels = False
        self.graph.axiss.append(top_axis)

        # create and add right axis
        right_axis = CaGraphYAxis(self.graph)
        right_axis.axis_style.side = 'right'
        right_axis.axis_style.draw_labels = False
        self.graph.axiss.append(right_axis)

        # create and add series to graph
        series1 = CaGraphSeriesLine(self.graph, 0, 1)
        series2 = CaGraphSeriesArea(self.graph, 0, 1)
        series3 = CaGraphSeriesLine(self.graph, 0, 1)

        self.graph.seriess.append(series2)
        self.graph.seriess.append(series3)
        self.graph.seriess.append(series1)

        # set line style
        series1.style.line_color = (1.0, 0.0, 0.0, 1.0)
        series1.style.line_width = 2.0
        series1.style.point_type = ''

        series2.style.line_color = (0.0, 1.0, 0.0, 1.0)
        series2.style.fill_color = (0.0, 1.0, 0.0, 0.3)
        series2.style.line_width = 2.0
        series2.style.point_type = ''

        series3.style.line_color = (0.0, 0.6, 0.0, 1.0)
        series3.style.line_width = 0.0
        series3.style.point_type = 'o'

        # add data to seriess
        for i in range(-360, 720):
            alpha = math.pi * i / 180.0

            series1.data.append((alpha, math.sin(alpha)))
            series2.data.append((alpha, math.cos(alpha)))

        for i in range(-360, 720, 20):
            alpha = math.pi * i / 180.0

            series3.data.append((alpha, math.cos(alpha)))

        # automaticaly set axis ranges
        self.graph.auto_set_range()

        # add grid
        self.graph.grid = CaGraphGrid(self.graph, 0, 1)

        # show wigdet
        self.graph.show()

        # draw to file
        self.graph.draw_to_file('example3.svg', 700, 300)
        self.graph.draw_to_file('example3.png', 700, 300)

    # signal handlers
    def on_main_window_delete_event(self, widget, obj):
        "on_main_window_delete_event activated"
        gtk.main_quit()