def test_23_linePlotCharts(self):
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib import colors
from reportlab.lib.units import inch
from reportlab.platypus import SimpleDocTemplate, Spacer, Paragraph
from reportlab.pdfbase import pdfmetrics
from reportlab.graphics.shapes import Drawing
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.graphics.charts.lineplots import LinePlot
from reportlab.graphics.widgets.markers import makeMarker
pdfmetrics.registerFont(TTFont('chsFont', 'STHeiti Light.ttc'))
stylesheet = getSampleStyleSheet()
elements = []
doc = SimpleDocTemplate("demo.pdf")
elements.append(Paragraph('<font name="chsFont">JY.zenist.song - ??</font>', stylesheet['Title']))
elements.append(Spacer(1,1*inch))
d = Drawing(400,200)
data = [
[(1,1), (2,2), (2.5,1), (3,3), (4,5)],
]
lp = LinePlot()
lp.x = 5
lp.y = 5
lp.height = 190
lp.width = 390
lp.data = data
lp.joinedLines = 1
lp.lines[0].symbol = makeMarker('FilledCircle')
d.add(lp)
elements.append(d)
doc.build(elements)
评论列表
文章目录