diff --git a/axis.go b/axis.go index eb0327f..4b9444c 100644 --- a/axis.go +++ b/axis.go @@ -31,20 +31,33 @@ import ( ) type AxisOption struct { - BoundaryGap *bool - Show *bool - Position string - SplitNumber int - ClassName string - StrokeColor drawing.Color - StrokeWidth float64 - TickLength int - TickShow *bool - LabelMargin int - FontSize float64 - Font *truetype.Font - FontColor drawing.Color - SplitLineShow bool + BoundaryGap *bool + // The flag for show axis, set this to *false will hide axis + Show *bool + // The position of axis, it can be 'left', 'top', 'right' or 'bottom' + Position string + // Number of segments that the axis is split into. Note that this number serves only as a recommendation. + SplitNumber int + ClassName string + // The line color of axis + StrokeColor drawing.Color + // The line width + StrokeWidth float64 + // The length of the axis tick + TickLength int + // The flag for show axis tick, set this to *false will hide axis tick + TickShow *bool + // The margin value of label + LabelMargin int + // The font size of label + FontSize float64 + // The font of label + Font *truetype.Font + // The color of label + FontColor drawing.Color + // The flag for show axis split line, set this to true will show axis split line + SplitLineShow bool + // The color of split line SplitLineColor drawing.Color } @@ -380,6 +393,7 @@ func (a *axis) measureAxis() int { return textMaxHeight + value } +// Render renders the axis for chart func (a *axis) Render() { style := a.style if isFalse(style.Show) { diff --git a/bar.go b/bar.go index eb88cb1..1090f6b 100644 --- a/bar.go +++ b/bar.go @@ -43,6 +43,7 @@ func (bs *BarStyle) Style() chart.Style { } } +// Bar renders bar for chart func (d *Draw) Bar(b chart.Box, style BarStyle) { s := style.Style() diff --git a/draw_test.go b/draw_test.go index ef449dd..65c2398 100644 --- a/draw_test.go +++ b/draw_test.go @@ -23,6 +23,8 @@ package charts import ( + "fmt" + "math" "testing" "github.com/stretchr/testify/assert" @@ -224,6 +226,20 @@ func TestDraw(t *testing.T) { }, result: "\\n", }, + // arcTo + { + fn: func(d *Draw) { + chart.Style{ + StrokeWidth: 1, + StrokeColor: drawing.ColorBlack, + FillColor: drawing.ColorBlue, + }.WriteToRenderer(d.Render) + d.arcTo(100, 100, 100, 100, 0, math.Pi/2) + d.Render.Close() + d.Render.FillStroke() + }, + result: "\\n", + }, } for _, tt := range tests { d, err := NewDraw(DrawOption{ @@ -237,6 +253,7 @@ func TestDraw(t *testing.T) { tt.fn(d) data, err := d.Bytes() assert.Nil(err) + fmt.Println(string(data)) assert.Equal(tt.result, string(data)) } } diff --git a/legend_test.go b/legend_test.go index aaadec7..0274269 100644 --- a/legend_test.go +++ b/legend_test.go @@ -133,6 +133,27 @@ func TestLegendRender(t *testing.T) { Bottom: 70, }, }, + { + newDraw: newDraw, + newLegend: func(d *Draw) *legend { + return NewLegend(d, LegendOption{ + Top: "10", + Left: "10%", + Data: []string{ + "Mon", + "Tue", + "Wed", + }, + Style: style, + Orient: OrientVertical, + }) + }, + box: chart.Box{ + Right: 101, + Bottom: 70, + }, + result: "\\nMonTueWed", + }, } for _, tt := range tests {