本文整理汇总了Python中reportlab.graphics.charts.textlabels.Label.x方法的典型用法代码示例。如果您正苦于以下问题:Python Label.x方法的具体用法?Python Label.x怎么用?Python Label.x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.graphics.charts.textlabels.Label
的用法示例。
在下文中一共展示了Label.x方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: colorTest
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import x [as 别名]
def colorTest(self):
from reportlab.graphics.shapes import Rect
from reportlab.graphics.charts.textlabels import Label
self.colorRangeStatic(130)
dim=25
width = self.PAGE_WIDTH-150
inrow = 8 #int(width/dim)
height = int(len(self.colors)/inrow)
if len(self.colors)%inrow > 0:
height +=1
height *= dim
drawing = Drawing(width, height)
for i,col in enumerate(self.colors):
x = (i%inrow)*dim
y = int(i/inrow)*dim
rec = Rect(x=x,y=y,width=dim,height=dim)
rec.fillColor = col
drawing.add(rec)
lab = Label()
lab.x=x+dim/2
lab.y=y+dim/2
lab.setText('%d'%i)
drawing.add(lab)
return drawing
示例2: _drawLabels
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import x [as 别名]
def _drawLabels(self, label, labelCenter, y, width):
"""
Draw the label given in a given area originating at (x,y) with width 'width'
"""
fontName = 'Times-Roman'
fontSize = 10
#Limit the length of the label to the boundaries of the chartAreaWidth
strWidth = self._stringWidth(label, fontName, fontSize)
#Calculate the area taken by one character
oneCharWidth = self._stringWidth(label[0], fontName, fontSize)
#If the given string needs more size, reduce the string to a length which fits
#in the given area
if strWidth > width:
maxPossibleLen = int(width/oneCharWidth)
label = label[:maxPossibleLen]
strWidth = self._stringWidth(label, fontName, fontSize)
x = (labelCenter - ((strWidth)/2))
Label_Graph = Label()
Label_Graph.fontName = fontName
Label_Graph.fontSize = fontSize
#Label_Graph.angle = 0
Label_Graph.boxAnchor = 'n'
Label_Graph.x = x
Label_Graph.y = y
Label_Graph.setText(label)
self.drawing.add(Label_Graph)
示例3: draw
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import x [as 别名]
def draw(self):
ascent = getFont(self.xValueAxis.labels.fontName).face.ascent
if ascent == 0:
ascent = 0.718 # default (from helvetica)
ascent = ascent * self.xValueAxis.labels.fontSize # normalize
# basic LinePlot - does the Axes, Ticks etc
lp = LinePlot.draw(self)
xLabel = self.xLabel
if xLabel: # Overall label for the X-axis
xl = Label()
xl.x = (self.x + self.width) / 2.0
xl.y = 0
xl.fontName = self.xValueAxis.labels.fontName
xl.fontSize = self.xValueAxis.labels.fontSize
xl.setText(xLabel)
lp.add(xl)
yLabel = self.yLabel
if yLabel: # Overall label for the Y-axis
yl = Label()
yl.angle = 90
yl.x = 0
yl.y = self.y + self.height / 2.0
yl.fontName = self.yValueAxis.labels.fontName
yl.fontSize = self.yValueAxis.labels.fontSize
yl.setText(yLabel)
lp.add(yl)
# do a bounding box - in the same style as the axes
if self.outerBorderOn:
lp.add(
Rect(
self.x,
self.y,
self.width,
self.height,
strokeColor=self.outerBorderColor,
strokeWidth=self.yValueAxis.strokeWidth,
fillColor=None,
)
)
lp.shift(self.leftPadding, self.bottomPadding)
return lp
示例4: title_draw
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import x [as 别名]
def title_draw(self, x, y, text):
chart_title = Label()
chart_title.x = x
chart_title.y = y
chart_title.fontName = 'FreeSansBold'
chart_title.fontSize = 16
chart_title.textAnchor = 'middle'
chart_title.setText(text)
return chart_title
示例5: cn_process
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import x [as 别名]
def cn_process(self, text, x, y, pathnow) :
pdfmetrics.registerFont(ttfonts.TTFont("font1",'simsun.ttc'))
title = Label()
title.fontName = "font1"
title.fontSize = 14
title_text = text
title._text = title_text
title.x = x
title.y = y
return (title)
示例6: setDescription
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import x [as 别名]
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')
示例7: setTitle
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import x [as 别名]
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')
示例8: addLabels
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import x [as 别名]
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)
示例9: setAxesLabels
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import x [as 别名]
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')
示例10: draw
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import x [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
示例11: range
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import x [as 别名]
legend.boxAnchor = 'sw'
legend.colorNamePairs = [(self.Color[i], names[i]) for i in range(len(names))]
legend.fontName = 'Helvetica'
legend.fontSize = 8
legend.dxTextSpace = 5
legend.dy = 5
legend.dx = 5
legend.deltay = 5
legend.alignment ='right'
drawing.add(lp)
drawing.add(legend)
if title != None:
label = Label()
label.x = w
label.y = h - 25
label.boxAnchor = 'se'
label.fontName = 'Helvetica'
label.fontSize = 10
label.setText(title)
drawing.add(label)
return drawing
def drawTable(self, data):
t = Table(data, None, None, None, 1, 1, 1)
extraStyle = []
for i in range(len(data[1:])):
if data[1:][i][0] == 'Free' or data[1:][i][0] == 'Used':
extraStyle.append(('BACKGROUND', (0, i + 1), (-1, i + 1), colors.orange))
if data[1:][i][0] == 'SwapUsage' or data[1:][i][0] == 'LMK File':