Skip to content

Commit

Permalink
all: apply govet fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sbinet committed May 22, 2020
1 parent cad1ea0 commit fe7fa68
Show file tree
Hide file tree
Showing 12 changed files with 159 additions and 152 deletions.
8 changes: 4 additions & 4 deletions plotter/barchart.go
Expand Up @@ -197,10 +197,10 @@ func (b *BarChart) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
// Thumbnail fulfills the plot.Thumbnailer interface.
func (b *BarChart) Thumbnail(c *draw.Canvas) {
pts := []vg.Point{
{c.Min.X, c.Min.Y},
{c.Min.X, c.Max.Y},
{c.Max.X, c.Max.Y},
{c.Max.X, c.Min.Y},
{X: c.Min.X, Y: c.Min.Y},
{X: c.Min.X, Y: c.Max.Y},
{X: c.Max.X, Y: c.Max.Y},
{X: c.Max.X, Y: c.Min.Y},
}
poly := c.ClipPolygonY(pts)
c.FillPolygon(b.Color, poly)
Expand Down
48 changes: 26 additions & 22 deletions plotter/boxplot.go
Expand Up @@ -207,25 +207,27 @@ func (b *BoxPlot) Plot(c draw.Canvas, plt *plot.Plot) {
aHigh := trY(b.AdjHigh)

box := c.ClipLinesY([]vg.Point{
{x - b.Width/2, q1},
{x - b.Width/2, q3},
{x + b.Width/2, q3},
{x + b.Width/2, q1},
{x - b.Width/2 - b.BoxStyle.Width/2, q1},
{X: x - b.Width/2, Y: q1},
{X: x - b.Width/2, Y: q3},
{X: x + b.Width/2, Y: q3},
{X: x + b.Width/2, Y: q1},
{X: x - b.Width/2 - b.BoxStyle.Width/2, Y: q1},
})
c.StrokeLines(b.BoxStyle, box...)

medLine := c.ClipLinesY([]vg.Point{
{x - b.Width/2, med},
{x + b.Width/2, med},
{X: x - b.Width/2, Y: med},
{X: x + b.Width/2, Y: med},
})
c.StrokeLines(b.MedianStyle, medLine...)

cap := b.CapWidth / 2
whisks := c.ClipLinesY([]vg.Point{{x, q3}, {x, aHigh}},
[]vg.Point{{x - cap, aHigh}, {x + cap, aHigh}},
[]vg.Point{{x, q1}, {x, aLow}},
[]vg.Point{{x - cap, aLow}, {x + cap, aLow}})
whisks := c.ClipLinesY(
[]vg.Point{{X: x, Y: q3}, {X: x, Y: aHigh}},
[]vg.Point{{X: x - cap, Y: aHigh}, {X: x + cap, Y: aHigh}},
[]vg.Point{{X: x, Y: q1}, {X: x, Y: aLow}},
[]vg.Point{{X: x - cap, Y: aLow}, {X: x + cap, Y: aLow}},
)
c.StrokeLines(b.WhiskerStyle, whisks...)

for _, out := range b.Outside {
Expand Down Expand Up @@ -333,25 +335,27 @@ func (b horizBoxPlot) Plot(c draw.Canvas, plt *plot.Plot) {
aHigh := trX(b.AdjHigh)

box := c.ClipLinesX([]vg.Point{
{q1, y - b.Width/2},
{q3, y - b.Width/2},
{q3, y + b.Width/2},
{q1, y + b.Width/2},
{q1, y - b.Width/2 - b.BoxStyle.Width/2},
{X: q1, Y: y - b.Width/2},
{X: q3, Y: y - b.Width/2},
{X: q3, Y: y + b.Width/2},
{X: q1, Y: y + b.Width/2},
{X: q1, Y: y - b.Width/2 - b.BoxStyle.Width/2},
})
c.StrokeLines(b.BoxStyle, box...)

medLine := c.ClipLinesX([]vg.Point{
{med, y - b.Width/2},
{med, y + b.Width/2},
{X: med, Y: y - b.Width/2},
{X: med, Y: y + b.Width/2},
})
c.StrokeLines(b.MedianStyle, medLine...)

cap := b.CapWidth / 2
whisks := c.ClipLinesX([]vg.Point{{q3, y}, {aHigh, y}},
[]vg.Point{{aHigh, y - cap}, {aHigh, y + cap}},
[]vg.Point{{q1, y}, {aLow, y}},
[]vg.Point{{aLow, y - cap}, {aLow, y + cap}})
whisks := c.ClipLinesX(
[]vg.Point{{X: q3, Y: y}, {X: aHigh, Y: y}},
[]vg.Point{{X: aHigh, Y: y - cap}, {X: aHigh, Y: y + cap}},
[]vg.Point{{X: q1, Y: y}, {X: aLow, Y: y}},
[]vg.Point{{X: aLow, Y: y - cap}, {X: aLow, Y: y + cap}},
)
c.StrokeLines(b.WhiskerStyle, whisks...)

for _, out := range b.Outside {
Expand Down
4 changes: 2 additions & 2 deletions plotter/errbars.go
Expand Up @@ -70,7 +70,7 @@ func (e *YErrorBars) Plot(c draw.Canvas, p *plot.Plot) {
ylow := trY(e.XYs[i].Y - math.Abs(err.Low))
yhigh := trY(e.XYs[i].Y + math.Abs(err.High))

bar := c.ClipLinesY([]vg.Point{{x, ylow}, {x, yhigh}})
bar := c.ClipLinesY([]vg.Point{{X: x, Y: ylow}, {X: x, Y: yhigh}})
c.StrokeLines(e.LineStyle, bar...)
e.drawCap(&c, x, ylow)
e.drawCap(&c, x, yhigh)
Expand Down Expand Up @@ -178,7 +178,7 @@ func (e *XErrorBars) Plot(c draw.Canvas, p *plot.Plot) {
xlow := trX(e.XYs[i].X - math.Abs(err.Low))
xhigh := trX(e.XYs[i].X + math.Abs(err.High))

bar := c.ClipLinesX([]vg.Point{{xlow, y}, {xhigh, y}})
bar := c.ClipLinesX([]vg.Point{{X: xlow, Y: y}, {X: xhigh, Y: y}})
c.StrokeLines(e.LineStyle, bar...)
e.drawCap(&c, xlow, y)
e.drawCap(&c, xhigh, y)
Expand Down
10 changes: 5 additions & 5 deletions plotter/glyphbox.go
Expand Up @@ -31,11 +31,11 @@ func (g GlyphBoxes) Plot(c draw.Canvas, plt *plot.Plot) {
x := c.X(b.X) + b.Rectangle.Min.X
y := c.Y(b.Y) + b.Rectangle.Min.Y
c.StrokeLines(g.LineStyle, []vg.Point{
{x, y},
{x + b.Rectangle.Size().X, y},
{x + b.Rectangle.Size().X, y + b.Rectangle.Size().Y},
{x, y + b.Rectangle.Size().Y},
{x, y},
{X: x, Y: y},
{X: x + b.Rectangle.Size().X, Y: y},
{X: x + b.Rectangle.Size().X, Y: y + b.Rectangle.Size().Y},
{X: x, Y: y + b.Rectangle.Size().Y},
{X: x, Y: y},
})
}
}
16 changes: 8 additions & 8 deletions plotter/histogram.go
Expand Up @@ -93,10 +93,10 @@ func (h *Histogram) Plot(c draw.Canvas, p *plot.Plot) {
xmin := trX(bin.Min)
xmax := trX(bin.Max)
pts := []vg.Point{
{xmin, ymin},
{xmax, ymin},
{xmax, ymax},
{xmin, ymax},
{X: xmin, Y: ymin},
{X: xmax, Y: ymin},
{X: xmax, Y: ymax},
{X: xmin, Y: ymax},
}
if h.FillColor != nil {
c.FillPolygon(h.FillColor, c.ClipPolygonXY(pts))
Expand Down Expand Up @@ -162,10 +162,10 @@ func (h *Histogram) Thumbnail(c *draw.Canvas) {
xmax := c.Max.X

pts := []vg.Point{
{xmin, ymin},
{xmax, ymin},
{xmax, ymax},
{xmin, ymax},
{X: xmin, Y: ymin},
{X: xmax, Y: ymin},
{X: xmax, Y: ymax},
{X: xmin, Y: ymax},
}
if h.FillColor != nil {
c.FillPolygon(h.FillColor, c.ClipPolygonXY(pts))
Expand Down
34 changes: 17 additions & 17 deletions plotter/sankey.go
Expand Up @@ -260,10 +260,10 @@ func (s *Sankey) Plot(c draw.Canvas, plt *plot.Plot) {

// Here we fill the stock bars.
pts := []vg.Point{
{catMin, valMin},
{catMin, valMax},
{catMax, valMax},
{catMax, valMin},
{X: catMin, Y: valMin},
{X: catMin, Y: valMax},
{X: catMax, Y: valMax},
{X: catMax, Y: valMin},
}
if color != nil {
c.FillPolygon(color, pts) // poly)
Expand All @@ -273,20 +273,20 @@ func (s *Sankey) Plot(c draw.Canvas, plt *plot.Plot) {

// Here we draw the bottom edge.
pts = []vg.Point{
{catMin, valMin},
{catMax, valMin},
{X: catMin, Y: valMin},
{X: catMax, Y: valMin},
}
c.StrokeLines(lineStyle, pts)

// Here we draw the top edge plus vertical edges where there are
// no flows connected.
pts = []vg.Point{
{catMin, valMax},
{catMax, valMax},
{X: catMin, Y: valMax},
{X: catMax, Y: valMax},
}
if stk.receptorValue < stk.sourceValue {
y := trVal(stk.max - (stk.sourceValue - stk.receptorValue))
pts = append([]vg.Point{{catMin, y}}, pts...)
pts = append([]vg.Point{{X: catMin, Y: y}}, pts...)
} else if stk.sourceValue < stk.receptorValue {
y := trVal(stk.max - (stk.receptorValue - stk.sourceValue))
pts = append(pts, vg.Point{X: catMax, Y: y})
Expand Down Expand Up @@ -449,26 +449,26 @@ type sankeyFlowThumbnailer struct {
func (t sankeyFlowThumbnailer) Thumbnail(c *draw.Canvas) {
// Here we draw the fill.
pts := []vg.Point{
{c.Min.X, c.Min.Y},
{c.Min.X, c.Max.Y},
{c.Max.X, c.Max.Y},
{c.Max.X, c.Min.Y},
{X: c.Min.X, Y: c.Min.Y},
{X: c.Min.X, Y: c.Max.Y},
{X: c.Max.X, Y: c.Max.Y},
{X: c.Max.X, Y: c.Min.Y},
}
poly := c.ClipPolygonY(pts)
c.FillPolygon(t.Color, poly)

// Here we draw the upper border.
pts = []vg.Point{
{c.Min.X, c.Max.Y},
{c.Max.X, c.Max.Y},
{X: c.Min.X, Y: c.Max.Y},
{X: c.Max.X, Y: c.Max.Y},
}
outline := c.ClipLinesY(pts)
c.StrokeLines(t.LineStyle, outline...)

// Here we draw the lower border.
pts = []vg.Point{
{c.Min.X, c.Min.Y},
{c.Max.X, c.Min.Y},
{X: c.Min.X, Y: c.Min.Y},
{X: c.Max.X, Y: c.Min.Y},
}
outline = c.ClipLinesY(pts)
c.StrokeLines(t.LineStyle, outline...)
Expand Down
5 changes: 4 additions & 1 deletion tools/bezier/bezier.go
Expand Up @@ -48,7 +48,10 @@ func (c Curve) Point(t float64) vg.Point {
c[0].Point = c[0].Control
u := t
for i, p := range c[1:] {
c[i+1].Point = vg.Point{p.Control.X * vg.Length(u), p.Control.Y * vg.Length(u)}
c[i+1].Point = vg.Point{
X: p.Control.X * vg.Length(u),
Y: p.Control.Y * vg.Length(u),
}
u *= t
}

Expand Down

0 comments on commit fe7fa68

Please sign in to comment.