Exemplo n.º 1
0
    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')
Exemplo n.º 2
0
    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')
Exemplo n.º 3
0
    def __init__(self):
        # create widget tree ...
        xml = gtk.glade.XML('example7.glade')

        # connect handlers
        xml.signal_autoconnect(self)

        # widgets
        self.main_window = xml.get_widget('main_window')
        self.vbox_graph = xml.get_widget('vbox_graph')
        self.label_xy0 = xml.get_widget('label_xy0')
        self.label_xy1 = xml.get_widget('label_xy1')

        # add graph
        self.graph = CaGraph(self.main_window)
        self.vbox_graph.pack_start(self.graph)

        # show pointer line
        self.graph.graph_style.draw_pointer = True

        # 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(CaGraphSeriesBar(self.graph, 0, 1))

        # add data to seriess
        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()

        # show x,y data in a label when the mouse is over the graph
        self.main_window.connect('motion-notify-event', self.motion_notify)

        # show wigdet
        self.graph.show()
Exemplo n.º 4
0
    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.main_window)
        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(CaGraphSeriesBar(self.graph, 0, 1))

        # add data to seriess
        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()

        # show wigdet
        self.graph.show()
Exemplo n.º 5
0
  def _pack_graph_widget(self, name):
    graph = CaGraph()
    graph.set_size_request(200, 200)

    placeholder = self.builder.get_object('placeholder_graph_%s' % name)
    placeholder.pack_start(graph)

    xAxis = CaGraphXAxis(graph)
    yAxis = CaGraphYAxis(graph)

    xAxis.min = 0
    xAxis.max = GRAPH_INTERVAL - 1
    xAxis.axis_style.draw_labels = False
    yAxis.axis_style.label_color = (0, 0, 0)

    graph.axiss.append(xAxis)
    graph.axiss.append(yAxis)

    series = CaGraphSeriesArea(graph, 0, 1)

    theme = gtkTools.Theme()
    primaryColor = theme.colors['normal']
    secondaryColor = theme.colors['insensitive']
    colors = { 'primary' : (primaryColor.red_float, primaryColor.green_float, primaryColor.blue_float, 0.5),
               'secondary' : (secondaryColor.red_float, secondaryColor.green_float, secondaryColor.blue_float, 0.5) }

    series.style.point_radius = 0.0
    series.style.line_color = colors[name]
    series.style.fill_color = colors[name]

    graph.seriess.append(series)
    graph.grid = CaGraphGrid(graph, 0, 1)

    self.graphs[name] = graph

    return graph
Exemplo n.º 6
0
    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')
Exemplo n.º 7
0
    def __init__(self):
        # create widget tree ...
        xml = gtk.glade.XML('example99.glade')

        # connect handlers
        xml.signal_autoconnect(self)

        # widgets
        self.main_window = xml.get_widget('main_window')
        self.vbox_graph = xml.get_widget('vbox_graph')
        self.label_xy = xml.get_widget('label_xy0')

        # add graph
        self.graph = CaGraph(self.main_window)
        self.vbox_graph.pack_start(self.graph)

        # show pointer line
        self.graph.graph_style.draw_pointer = True
        self.graph.graph_style.draw_pointer_y = True

        # create and add axiss to graph
        xaxis = CaGraphXAxis(self.graph)
        xaxis.axis_style.label_format = '%d'
        xaxis.axis_style.side = 'top'
        yaxis = CaGraphYAxis(self.graph)
        yaxis.axis_style.draw_labels = False
        yaxis.axis_style.draw_tics = False
        self.graph.axiss.append(xaxis)
        self.graph.axiss.append(yaxis)

        # create and add top axis
        top_axis = CaGraphXAxis(self.graph)
        top_axis.axis_style.label_format = '%d'
        top_axis.axis_style.side = 'bottom'
        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
        right_axis.axis_style.draw_tics = False
        self.graph.axiss.append(right_axis)

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

        # add data to seriess
        self.graph.seriess[0].data = [(32.0, 40.0, 10.0), (10.0, 15.0, 20.0),
                                      (33.0, 50.0, 30.0), (38, 42.0, 40.0),
                                      (55.0, 78.0, 50.0), (65.0, 90.0, 60.0),
                                      (75.0, 84.0, 70.0)]

        self.graph.seriess[1].data = [(32.0, 10.0, u'sample 89A'),
                                      (10.0, 20.0, u'sample 18'),
                                      (38, 40.0, u'sample 46'),
                                      (55.0, 50.0, u'sample 89B')]

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

        self.graph.grid = CaGraphGrid(self.graph, 0, 1)
        self.graph.grid.style.line_color = (0, 0.5, 0, 1.0)
        self.graph.grid.style.zero_line_color = (0, 0, 0, 0)

        # show x,y data in a label when the mouse is over the graph
        self.main_window.connect('motion-notify-event', self.motion_notify)

        # show wigdet
        self.graph.show()
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
    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)