本文整理汇总了Python中reportlab.graphics.charts.textlabels.Label.angle方法的典型用法代码示例。如果您正苦于以下问题:Python Label.angle方法的具体用法?Python Label.angle怎么用?Python Label.angle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.graphics.charts.textlabels.Label
的用法示例。
在下文中一共展示了Label.angle方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _drawLabels
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [as 别名]
def _drawLabels(self, Title, xAxis, yAxis):
self.graphCenterX = self.width/2
self.graphCenterY = self.height/2
Label_Xaxis = Label()
Label_Xaxis.fontSize = 7
Label_Xaxis.angle = 0
Label_Xaxis.dx = self.graphCenterX - 50
Label_Xaxis.dy = 0
Label_Xaxis.boxAnchor = 's'
Label_Xaxis.setText(xAxis)
self.drawing.add(Label_Xaxis)
Label_Yaxis = Label()
Label_Yaxis.fontSize = 7
Label_Yaxis.angle = 90
Label_Yaxis.boxAnchor = 'n'
Label_Yaxis.dx = -5
Label_Yaxis.dy = self.graphCenterY
Label_Yaxis.setText(yAxis)
self.drawing.add(Label_Yaxis)
Label_Graph = Label()
Label_Graph.fontSize = 10
Label_Graph.angle = 0
Label_Graph.boxAnchor = 'n'
Label_Graph.dx = self.graphCenterX - 50
Label_Graph.dy = self.height
Label_Graph.setText(Title)
self.drawing.add(Label_Graph)
示例2: draw_travels
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [as 别名]
def draw_travels(self):
for p in self.world.packets:
if self.detailed:
txt = p.command()
else:
txt = "(%d) %s" % (p.number, p.description)
last_action = (0,0)
for ts in p.trip:
action = self.packet_actions[ts.action]
if ts.actor not in self.verticals:
self.verticals[ts.actor] = self.verticals[ts.actor.node]
x2,y2 = self.verticals[ts.actor], -ts.time*self.yzoom
if action.sprite:
self.sequence_diagram.add(shapes.Circle(x2, y2,
action.size, fillColor=action.color, strokeWidth=1 ))
if action.travel:
if action.travel_desc:
# self.sequence_diagram.add(shapes.String((last_action[0] + x)/2,(last_action[1]+y)/2, label, fill=colors.black, textAnchor = 'middle'))
x1, y1 = last_action[0], last_action[1]
l = Label()
l.setText(txt)
l.angle = atan2((y2-y1)/2, (x2-x1))*360.0/pi
l.dy = 10
l.setOrigin((x1 + x2)/2,(y1+y2)/2)
self.sequence_diagram.add(l)
#anchor = Paragraph('<a name="diagram%d"/>' %p.number, styles['Normal'])
self.sequence_diagram.add(shapes.Line(last_action[0],last_action[1],x2,y2, strokeColor=colors.black, strokeWidth=1))
self.max_y = min(y2, self.max_y, last_action[1])
last_action = (x2,y2)
示例3: draw
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [as 别名]
def draw(self):
# general widget bits
w = float(self.length)
h = float(self.height)
g = shapes.Group()
body = shapes.Polygon(
[self.x-0.5*w, self.y-0.5*w,
self.x-0.5*w, self.y+0.5*w,
self.x+0.5*w, self.y],
fillColor=self.fillColor,
strokeColor=self.strokeColor,
strokeWidth=self.strokeWidth)
g.add(body)
if self.label:
b = g.getBounds()
s = Label()
s.setText(self.label)
s.setOrigin(self.x+0.5*w, self.y-h/2+b[3]-b[1]+4)
s.boxAnchor = self.boxAnchor
s.textAnchor = self.textAnchor
s.fontName = 'Helvetica'
s.fontSize = self.fontSize
s.angle = self.labelAngle
g.add(s)
return g
示例4: addLabel
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [as 别名]
def addLabel(drawing, x, y, text, fontName='Helvetica', fontSize=11, dy=0,
angle=0, boxAnchor='sw', textAnchor='start'):
"""Add a label to the drawing.
This interface here is inconsistent in that it requires pixel coords. FIX
This just sets convenient defaults for Label."""
label = Label()
label.setText(text)
label.setOrigin(x, y)
label.fontName = fontName
label.fontSize = fontSize
label.boxAnchor = boxAnchor
label.textAnchor = textAnchor
label.dy = dy
label.angle = angle
drawing.add(label)
示例5: draw
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [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
示例6: addAxis
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [as 别名]
def addAxis(drawing, xmap, y, strokeWidth=1, minorStrokeWidth=0.5,
tickDir='down', autoTicks=False, nTicks=20, tickLen=5, fontSize=10, nMinorTicks=80,
minorTickLen=2, angle=0, dx=0, dy=-2, textAnchor='middle', boxAnchor=None,
scale=1.0, format='%i'):
"""Add a horizontal axis to the drawing.
To do: Round tick positions
"""
line = Line(xmap.x0, y, xmap.x1, y, strokeWidth=strokeWidth)
drawing.add(line)
if not boxAnchor:
if tickDir=='down':
boxAnchor = 'n'
else:
boxAnchor = 's'
signum = {'up': -1, 'down': 1}[tickDir]
if nTicks>0:
ticks = tick_generator(xmap.start, xmap.end, n=nTicks, convert=int)
for p in ticks:
x = xmap(p)
line = Line(x, y, x, y-signum*tickLen, strokeWidth=strokeWidth)
drawing.add(line)
s = Label()
s.setOrigin(x, y-signum*tickLen)
s.setText(format % (p/scale))
s.dx = dx
s.dy = signum*dy
s.fontName = 'Helvetica'
s.fontSize = fontSize
s.textAnchor = textAnchor
s.boxAnchor = boxAnchor
s.angle = angle
drawing.add(s)
minorticks = tick_generator(xmap.start, xmap.end, n=nMinorTicks, convert=int)
for p in minorticks:
x = xmap(p)
line = Line(x, y, x, y-signum*minorTickLen, strokeWidth=minorStrokeWidth)
drawing.add(line)
示例7: addLabels
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [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)
示例8: setAxesLabels
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [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')
示例9: Drawing
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [as 别名]
d.add(lab)
""")
from reportlab.graphics import shapes
from reportlab.graphics.charts.textlabels import Label
d = Drawing(200, 100)
# mark the origin of the label
d.add(Circle(100,90, 5, fillColor=colors.green))
lab = Label()
lab.setOrigin(100,90)
lab.boxAnchor = 'ne'
lab.angle = 45
lab.dx = 0
lab.dy = -20
lab.boxStrokeColor = colors.green
lab.setText('Some\nMulti-Line\nLabel')
d.add(lab)
draw(d, 'Label example')
disc("""
In the drawing above, the label is defined relative to the green blob.
The text box should have its north-east corner ten points down from
the origin, and be rotated by 45 degrees about that corner.
示例10: _rawDraw
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [as 别名]
def _rawDraw(self, x, y):
from reportlab.lib import colors
from reportlab.graphics.shapes import Drawing, Line, String, STATE_DEFAULTS
from reportlab.graphics.charts.axes import XCategoryAxis,YValueAxis
from reportlab.graphics.charts.textlabels import Label
from reportlab.graphics.charts.barcharts import VerticalBarChart
self.originX = x
self.originY = y
self._setScale([self.dataBar])
(x1, y1, Width, Height) = self._getGraphRegion(x, y)
#Build the graph
self.drawing = Drawing(self.width, self.height)
#Size of the Axis
SizeXaxis = 14
countSteps = int(self.valueMax / self.valueStep)
SizeYaxis = 0.0
for n in range(countSteps + 1):
eachValue = self.valueMin + n * self.valueStep
textString = self._customSecondsLabelFormat( eachValue )
SizeYaxis = max(SizeYaxis, self._stringWidth(textString, STATE_DEFAULTS['fontName'], STATE_DEFAULTS['fontSize']) )
bc = VerticalBarChart()
SizeYaxis += bc.valueAxis.tickLeft
bc.x = x1 - x + SizeYaxis
bc.y = y1 - y + SizeXaxis
bc.height = Height - SizeXaxis
bc.width = Width - SizeYaxis
self.graphCenterX = bc.x + bc.width/2
self.graphCenterY = bc.y + bc.height/2
if self.validData:
# add valid data to chart
bc.data = self.dataBar
bc.categoryAxis.categoryNames = self.dataNames
# axis values
bc.valueAxis.valueMin = self.valueMin
bc.valueAxis.valueMax = self.valueMax
bc.valueAxis.valueStep = self.valueStep
# add value labels above bars
bc.barLabelFormat = self._customSecondsLabelFormat
bc.barLabels.dy = 0.08*inch
bc.barLabels.fontSize = 6
else:
# no valid data
bc.data = [ (0, ), ]
bc.categoryAxis.categoryNames = [ '' ]
bc.valueAxis.valueMin = 0
bc.valueAxis.valueMax = 1
bc.valueAxis.valueStep = 1
Nodata = Label()
Nodata.fontSize = 12
Nodata.angle = 0
Nodata.boxAnchor = 'c'
Nodata.dx = self.graphCenterX
Nodata.dy = self.graphCenterY
Nodata.setText("NO VALID DATA")
self.drawing.add(Nodata)
# chart formatting
(R,G,B) = VeriwaveYellow
bc.bars[0].fillColor = colors.Color(R,G,B)
bc.valueAxis.labelTextFormat = self._customSecondsLabelFormat
# axis labels
bc.categoryAxis.labels.boxAnchor = 'c'
bc.categoryAxis.labels.dx = 0
bc.categoryAxis.labels.dy = -10
bc.categoryAxis.labels.angle = 0
bc.categoryAxis.labels.fontSize = 8
# add chart
self.drawing.add(bc)
#Adjust the labels to be the center of the graph
self._drawLabels(self.title, "", "")
# Add Legend in upper right corner
legendHeight = 9
legendX = bc.x + 5
legendY = bc.y + bc.height - 12
self.drawing.add(Line(legendX, legendY + 3 , legendX + 20, legendY + 3, strokeColor=bc.bars[0].fillColor, strokeWidth=3 ))
self.drawing.add(String(legendX + 22, legendY, 'MIN', fontName='Helvetica', fontSize=8))
legendY -= legendHeight
self.drawing.add(Line(legendX, legendY + 3 , legendX + 20, legendY + 3, strokeColor=bc.bars[1].fillColor, strokeWidth=3 ))
self.drawing.add(String(legendX + 22, legendY, 'MAX', fontName='Helvetica', fontSize=8))
legendY -= legendHeight
self.drawing.add(Line(legendX, legendY + 3 , legendX + 20, legendY + 3, strokeColor=bc.bars[2].fillColor, strokeWidth=3 ))
self.drawing.add(String(legendX + 22, legendY, 'AVG', fontName='Helvetica', fontSize=8))
legendY -= legendHeight
示例11: makeSummary
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [as 别名]
def makeSummary(self, stype):
logger.debug('StartQT4::makeSummary(%s)' % stype)
pinfo = self.imageViews[-1].getSummaryDemographics()
if pinfo is None:
return
reportname = self.imageViews[-1].getReportName()+'.pdf'
filename = QtGui.QFileDialog.getSaveFileName(self, directory=reportname, filter='PDF Files *.pdf(*.pdf);;All Files *(*)')
#filename = QtGui.QFileDialog.getSaveFileName(self, filter='PDF Files *.pdf(*.pdf);;All Files *(*)')
if len(filename) == 0:
return
doc = SimpleDocTemplate(str(filename), pagesize=A4, rightMargin=1.5*cm, leftMargin=2*cm, topMargin=2*cm, bottomMargin=3*cm)
elements = []
#data = pinfo.items()
for iv in self.imageViews:
vt = iv.getVelocityText()
if stype == 'BOTH' or stype == iv.getViewShortName():
pinfo.append(vt)
t=Table(pinfo, rowHeights=12)
t.setStyle(TableStyle([('BACKGROUND',(1,1),(-2,-2),colors.green),
('TEXTCOLOR',(0,0),(1,-1),colors.black),
('ALIGNMENT', (0,0),(0,-1), 'RIGHT')]))
elements.append(t)
for iv in self.imageViews:
if stype == 'BOTH' or stype == iv.getViewShortName():
drawing = Drawing(400, 280)
cd = iv.getDataPointer()
vt = iv.getVelocityText()
pinfo.append(vt)
#ydata = cd.getCOMYScaled(False, 'mm').tolist()
ydata = cd.getCOMYScaled(True, 'mm').tolist()
xPlaneFit = cd.getYPlaneFit(units='mm', bothAxes=True).tolist()
vdata = cd.getVelocitySlopeScaled(units='mm', bothAxes=True)
gdata = [ydata, xPlaneFit]
if vdata is not None:
gdata.append(vdata.tolist())
title = Label()
title.setOrigin(150, 240)
title.setText(iv.getViewName())
ylabel = Label()
ylabel.setOrigin(0, 100)
ylabel.angle = 90
ylabel.setText("Millimeters")
xlabel = Label()
xlabel.setOrigin(70, 0)
xlabel.setText("Seconds")
lp = LinePlot()
lp.height = 230
lp.width = 400
lp.data = gdata
lp.lines[0].strokeColor = colors.blue
lp.lines[1].strokeColor = colors.red
lp.lines[2].strokeColor = colors.green
#lp.xValueAxis.xLabel = "Seconds"
drawing.add(title)
drawing.add(ylabel)
drawing.add(xlabel)
drawing.add(lp)
elements.append(drawing)
doc.build(elements, onFirstPage=self.pdfHeaderFooter, onLaterPages=self.pdfHeaderFooter)
示例12: draw
# 需要导入模块: from reportlab.graphics.charts.textlabels import Label [as 别名]
# 或者: from reportlab.graphics.charts.textlabels.Label import angle [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