diff --git a/chart_option_test.go b/chart_option_test.go
index 1238422..0cdc2aa 100644
--- a/chart_option_test.go
+++ b/chart_option_test.go
@@ -204,7 +204,7 @@ func TestLineRender(t *testing.T) {
assert.Nil(err)
data, err := p.Bytes()
assert.Nil(err)
- assert.Equal("", string(data))
+ assert.Equal("", string(data))
}
func TestBarRender(t *testing.T) {
@@ -277,7 +277,7 @@ func TestBarRender(t *testing.T) {
assert.Nil(err)
data, err := p.Bytes()
assert.Nil(err)
- assert.Equal("", string(data))
+ assert.Equal("", string(data))
}
func TestHorizontalBarRender(t *testing.T) {
diff --git a/legend.go b/legend.go
index d3b135e..820f1b5 100644
--- a/legend.go
+++ b/legend.go
@@ -146,6 +146,8 @@ func (l *legendPainter) Render() (Box, error) {
width += item.Width()
}
}
+ // 增加padding
+ itemMaxHeight += 10
if opt.Orient == OrientVertical {
width = maxTextWidth + textOffset + legendWidth
height = offset * len(opt.Data)
@@ -207,9 +209,10 @@ func (l *legendPainter) Render() (Box, error) {
FillColor: color,
StrokeColor: color,
})
- if x0+measureList[index].Width() > p.Width() {
+ if x0+measureList[index].Width()+textOffset+offset+legendWidth > p.Width() {
x0 = 0
- y0 += itemMaxHeight
+ y += itemMaxHeight
+ y0 = y
}
if opt.Align != AlignRight {
x0 = drawIcon(y0, x0)
diff --git a/line_chart_test.go b/line_chart_test.go
index 856cdf3..ff80741 100644
--- a/line_chart_test.go
+++ b/line_chart_test.go
@@ -117,7 +117,7 @@ func TestLineChart(t *testing.T) {
}
return p.Bytes()
},
- result: "",
+ result: "",
},
{
render: func(p *Painter) ([]byte, error) {
@@ -201,7 +201,7 @@ func TestLineChart(t *testing.T) {
}
return p.Bytes()
},
- result: "",
+ result: "",
},
}