我们的脚本读取一些数据并使用折线图生成报告。 但Y轴值可能大于Y轴的最大值,或小于最小值。在这种情况下,我们只需要显示适合边界的部分。但它超出了图表的边界。 有没有办法在情节的边界保持线条图?
def add_chart(self, x, y, width, height, drawing, data, total_length):
lc = LinePlot()
lc.x, lc.y = x, y
lc.width, lc.height = width, height
lc.data = data
lc.xValueAxis.valueMin = 0
lc.xValueAxis.valueMax = total_length
lc.xValueAxis.valueStep = total_length / 10
lc.xValueAxis.labelTextFormat = seconds_to_hms
lc.xValueAxis.labels.fontSize = 8
lc.yValueAxis.valueMin = 0
lc.yValueAxis.valueMax = 1500
lc.yValueAxis.valueStep = (lc.yValueAxis.valueMax - lc.yValueAxis.valueMin) / 10
lc.yValueAxis.visibleGrid = 1
drawing.add(lc)
drawing.drawOn(self.canvas, 0, 0)