当前位置: 首页>>代码示例>>Python>>正文


Python Label.draw方法代码示例

本文整理汇总了Python中reportlab.graphics.charts.textlabels.Label.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Label.draw方法的具体用法?Python Label.draw怎么用?Python Label.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reportlab.graphics.charts.textlabels.Label的用法示例。


在下文中一共展示了Label.draw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw

# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import draw [as 别名]
    def draw(self):
        g = Group()

        #box
        g.add(Rect(self.x,self.y,len(self.xlabels)*self.gridDivWidth,len(self.ylabels)*self.gridDivWidth,
                   strokeColor=self.gridColor,
                   strokeWidth=self.strokeWidth,
                   fillColor=None))

        #internal gridding
        for f in range (1,len(self.ylabels)):
            #horizontal
            g.add(Line(strokeColor=self.gridColor,
                       strokeWidth=self.strokeWidth,
                       x1 = self.x,
                       y1 = self.y+f*self.gridDivWidth,
                       x2 = self.x+len(self.xlabels)*self.gridDivWidth,
                       y2 = self.y+f*self.gridDivWidth))
        for f in range (1,len(self.xlabels)):
            #vertical
            g.add(Line(strokeColor=self.gridColor,
                       strokeWidth=self.strokeWidth,
                       x1 = self.x+f*self.gridDivWidth,
                       y1 = self.y,
                       x2 = self.x+f*self.gridDivWidth,
                       y2 = self.y+len(self.ylabels)*self.gridDivWidth))

        # draw the 'dot'
        g.add(Circle(strokeColor=self.gridColor,
                     strokeWidth=self.strokeWidth,
                     fillColor=self.dotColor,
                     cx = self.x+(self.dotXPosition*self.gridDivWidth),
                     cy = self.y+(self.dotYPosition*self.gridDivWidth),
                     r = self.dotDiameter/2.0))

        #used for centering y-labels (below)
        ascent=getFont(self.labelFontName).face.ascent
        if ascent==0:
            ascent=0.718 # default (from helvetica)
        ascent=ascent*self.labelFontSize # normalize

        #do y-labels
        if self.ylabels != None:
            for f in range (len(self.ylabels)-1,-1,-1):
                if self.ylabels[f]!= None:
                    g.add(String(strokeColor=self.gridColor,
                             text = self.ylabels[f],
                             fontName = self.labelFontName,
                             fontSize = self.labelFontSize,
                             fillColor=_PCMYK_black,
                             x = self.x-self.labelOffset,
                             y = self.y+(f*self.gridDivWidth+(self.gridDivWidth-ascent)/2.0),
                             textAnchor = 'end'))

        #do x-labels
        if self.xlabels != None:
            for f in range (0,len(self.xlabels)):
                if self.xlabels[f]!= None:
                    l=Label()
                    l.x=self.x+(f*self.gridDivWidth)+(self.gridDivWidth+ascent)/2.0
                    l.y=self.y+(len(self.ylabels)*self.gridDivWidth)+self.labelOffset
                    l.angle=90
                    l.textAnchor='start'
                    l.fontName = self.labelFontName
                    l.fontSize = self.labelFontSize
                    l.fillColor = _PCMYK_black
                    l.setText(self.xlabels[f])
                    l.boxAnchor = 'sw'
                    l.draw()
                    g.add(l)

        return g
开发者ID:AceZOfZSpades,项目名称:RankPanda,代码行数:74,代码来源:dotbox.py


注:本文中的reportlab.graphics.charts.textlabels.Label.draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。