Exemplo n.º 1
0
    def getTalkRect(self, startTime, duration, trackId, text):
        "Return shapes for a specific talk"
        g = Group()
        y_bottom = self.scaleTime(startTime + duration)
        y_top = self.scaleTime(startTime)
        y_height = y_top - y_bottom

        if trackId is None:
            #spans all columns
            x = self._colLeftEdges[1]
            width = self.width - self._colWidths[0]
        else:
            #trackId is 1-based and these arrays have the margin info in column
            #zero, so no need to add 1
            x = self._colLeftEdges[trackId]
            width = self._colWidths[trackId]

        lab = Label()
        lab.setText(text)
        lab.setOrigin(x + 0.5 * width, y_bottom + 0.5 * y_height)
        lab.boxAnchor = 'c'
        lab.width = width
        lab.height = y_height
        lab.fontSize = 6

        r = Rect(x, y_bottom, width, y_height, fillColor=colors.cyan)
        g.add(r)
        g.add(lab)

        #now for a label
        # would expect to color-code and add text
        return g
Exemplo n.º 2
0
    def getTalkRect(self, startTime, duration, trackId, text):
        "Return shapes for a specific talk"
        g = Group()
        y_bottom = self.scaleTime(startTime + duration)
        y_top = self.scaleTime(startTime)
        y_height = y_top - y_bottom

        if trackId is None:
            #spans all columns
            x = self._colLeftEdges[1]
            width = self.width - self._colWidths[0]
        else:
            #trackId is 1-based and these arrays have the margin info in column
            #zero, so no need to add 1
            x = self._colLeftEdges[trackId]
            width = self._colWidths[trackId]

        lab = Label()
        lab.setText(text)
        lab.setOrigin(x + 0.5*width, y_bottom+0.5*y_height)
        lab.boxAnchor = 'c'
        lab.width = width
        lab.height = y_height
        lab.fontSize = 6

        r = Rect(x, y_bottom, width, y_height, fillColor=colors.cyan)
        g.add(r)
        g.add(lab)

        #now for a label
        # would expect to color-code and add text
        return g
Exemplo n.º 3
0
 def setDescription(self):
     desc = Label()        
     desc.fontName = 'Helvetica'
     desc.fontSize = 12
     desc.x = 230
     desc.y = 10
     desc._text = self._data_dict.get('description', '')
     desc.maxWidth = 280
     desc.height = 20
     desc.textAnchor ='middle'
     self.add(desc, name='Description')
Exemplo n.º 4
0
 def setTitle(self):
     title = Label()        
     title.fontName = 'Helvetica-Bold'
     title.fontSize = 12
     title.x = 300
     title.y = 335
     title._text = self._data_dict.get('title', '')
     title.maxWidth = 180
     title.height = 20
     title.textAnchor ='middle'
     self.add(title, name='Title')
Exemplo n.º 5
0
    def addLabels(self,drawing,title=None,xlabel=None,ylabel=None):
        from reportlab.graphics.charts.textlabels import Label
        if not title is None:
            Title = Label()
            Title.fontName = 'Helvetica-Bold'
            Title.fontSize = 7
            Title.x = drawing.width/2
            Title.y = drawing.height-25
            Title._text = title
            Title.maxWidth = 180
            Title.height = 20
            Title.textAnchor ='middle'
            drawing.add(Title)

        if not xlabel is None:
            XLabel = Label()
            XLabel.fontName = 'Helvetica'
            XLabel.fontSize = 7
            XLabel.x = drawing.width/2
            XLabel.y = 10
            XLabel.textAnchor ='middle'
            XLabel.maxWidth = 100
            XLabel.height = 20
            XLabel._text = xlabel
            drawing.add(XLabel)

        if not ylabel is None:
            YLabel = Label()
            YLabel.fontName = 'Helvetica'
            YLabel.fontSize = 7
            YLabel.x = 12
            YLabel.y = drawing.height/2
            YLabel.angle = 90
            YLabel.textAnchor ='middle'
            YLabel.maxWidth = 100
            YLabel.height = 20
            YLabel._text = ylabel
            drawing.add(YLabel)
Exemplo n.º 6
0
    def setAxesLabels(self):
        xlabel = Label()
        xlabel.fontName = 'Helvetica'
        xlabel.fontSize = 12
        xlabel.x = 450
        xlabel.y = 40
        xlabel._text = self._data_dict.get('xlabel', '')
        xlabel.maxWidth = 180
        xlabel.height = 20
        xlabel.textAnchor ='middle'
        self.add(xlabel, name='xlabel')

        ylabel = Label()
        ylabel.fontName = 'Helvetica'
        ylabel.fontSize = 12
        ylabel.x = 20
        ylabel.y = 210
        ylabel.angle = 90
        ylabel._text = self._data_dict.get('ylabel', '')
        ylabel.maxWidth = 180
        ylabel.height = 20
        ylabel.textAnchor ='middle'
        self.add(ylabel, name='ylabel')
Exemplo n.º 7
0
    def draw_line(self, line_data, *args, **kw):
        drawing = Drawing(400, 200)
        lp = LinePlot()
        lp.x = 30
        lp.y = -20
        lp.height = 200
        lp.width = 400
        lp.data = line_data
        lp.xValueAxis.labels.fontName = 'Helvetica'
        lp.xValueAxis.labels.fontSize = 7
        lp.xValueAxis.forceZero = 0
        lp.xValueAxis.avoidBoundFrac = 1
        lp.xValueAxis.gridEnd = 115
        lp.xValueAxis.tickDown = 3
        lp.xValueAxis.labelTextFormat = lambda x: time.strftime(
            '%Y-%m-%d %H:%M:%S', time.localtime(int(x) / 1000))

        lp.yValueAxis.tickLeft = 3
        lp.yValueAxis.labels.fontName = 'Helvetica'
        lp.yValueAxis.labels.fontSize = 7
        for i in range(len(line_data)):
            lp.lines[i].strokeColor = colors.toColor('hsl(%s,80%%,40%%)' %
                                                     (i * 60))
        drawing.add(lp)

        title = Label()
        title.fontName = 'Helvetica-Bold'
        title.fontSize = 14
        title.x = 200
        title.y = 180
        title._text = 'Chart Title'
        title.maxWidth = 180
        title.height = 20
        title.textAnchor = 'middle'
        drawing.add(title)

        return drawing