fix(export): 裁剪超出范围的曲线并修正 PDF 纵轴标签
- 共享几何将曲线裁剪到绘图矩形,避免超出显式 range 的曲线覆盖 PDF 其他内容 - PDF 纵轴标签改为组内局部坐标 + 先平移后旋转,标签边界落回 Drawing 范围内 - 更新 pdf.py 模块说明:function_plot 已内嵌矢量图 - 新增曲线裁剪与纵轴标签边界回归测试 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -89,15 +89,19 @@ def _build_drawing(geo: PlotGeometry) -> Drawing:
|
||||
)
|
||||
)
|
||||
if geo.ylabel:
|
||||
# 竖向标签:rotate(90) 在 y-up 坐标下等价于 SVG 的 rotate(-90)
|
||||
# 竖向标签:Group.rotate(90) 在 y-up 坐标下等价于 SVG 的 rotate(-90)。
|
||||
# 文本放在组内局部坐标 (0,0),先平移后旋转得到 T·R(先绕原点旋转、再平移到
|
||||
# 目标位置),避免用绝对坐标定位又用相同坐标当旋转中心造成的重复变换,
|
||||
# 后者会把标签甩到画布之外(负 x 区域)。
|
||||
label = Group()
|
||||
label.add(
|
||||
String(
|
||||
16, geo.height / 2, geo.ylabel,
|
||||
0, 0, geo.ylabel,
|
||||
fontName=_FONT, fontSize=_LABEL_FONT_SIZE, fillColor=_LABEL_COLOR, textAnchor="middle",
|
||||
)
|
||||
)
|
||||
label.rotate(90, 16, geo.height / 2)
|
||||
label.translate(16, geo.height / 2)
|
||||
label.rotate(90)
|
||||
drawing.add(label)
|
||||
|
||||
return drawing
|
||||
|
||||
Reference in New Issue
Block a user