diff --git a/chart_option_test.go b/chart_option_test.go
index a025c25..1238422 100644
--- a/chart_option_test.go
+++ b/chart_option_test.go
@@ -368,7 +368,7 @@ func TestPieRender(t *testing.T) {
assert.Nil(err)
data, err := p.Bytes()
assert.Nil(err)
- assert.Equal("", string(data))
+ assert.Equal("", string(data))
}
func TestRadarRender(t *testing.T) {
diff --git a/charts.go b/charts.go
index 41802d9..36bb17e 100644
--- a/charts.go
+++ b/charts.go
@@ -136,9 +136,14 @@ func defaultRender(p *Painter, opt defaultRenderOption) (*defaultRenderResult, e
return nil, err
}
+ top := chart.MaxInt(legendHeight, titleBox.Height())
+ // 如果是垂直方式,则不计算legend高度
+ if opt.LegendOption.Orient == OrientVertical {
+ top = titleBox.Height()
+ }
p = p.Child(PainterPaddingOption(Box{
// 标题下留白
- Top: chart.MaxInt(legendHeight, titleBox.Height()) + 20,
+ Top: top + 20,
}))
}
diff --git a/pie_chart_test.go b/pie_chart_test.go
index 070fb03..c373a7e 100644
--- a/pie_chart_test.go
+++ b/pie_chart_test.go
@@ -78,7 +78,7 @@ func TestPieChart(t *testing.T) {
}
return p.Bytes()
},
- result: "",
+ result: "",
},
}
for _, tt := range tests {