This commit is contained in:
恍兮惚兮 2024-05-06 18:30:54 +08:00
parent d648913f66
commit b56ecb12c2

View File

@ -116,14 +116,22 @@ class chartwidget(QWidget):
painter.drawText( painter.drawText(
x2 - self.fmetrics.width(text) // 2, y2 - 10, text x2 - self.fmetrics.width(text) // 2, y2 - 10, text
) # value ) # value
lastx2 = -999
for i, (x, y) in enumerate(points): for i, (x, y) in enumerate(points):
painter.drawLine(x, ymargin + height, x, ymargin + height + 5) # 刻度线 painter.drawLine(x, ymargin + height, x, ymargin + height + 5) # 刻度线
thisw = self.fmetrics.width(x_labels[i])
thisx = x - thisw // 2
if thisx > lastx2:
painter.drawText( painter.drawText(
x - self.fmetrics.width(x_labels[i]) // 2, thisx,
ymargin + height + 20, ymargin + height + 20,
x_labels[i], x_labels[i],
) # 标签 ) # 标签
lastx2 = thisx + thisw
except: except:
print_exc() print_exc()