MCPcopy Index your code
hub / github.com/gonum/plot / padX

Function padX

plot.go:257–277  ·  view source on GitHub ↗

padX returns a draw.Canvas that is padded horizontally so that glyphs will no be clipped.

(p *Plot, c draw.Canvas)

Source from the content-addressed store, hash-verified

255// padX returns a draw.Canvas that is padded horizontally
256// so that glyphs will no be clipped.
257func padX(p *Plot, c draw.Canvas) draw.Canvas {
258 glyphs := p.GlyphBoxes(p)
259 l := leftMost(&c, glyphs)
260 xAxis := horizontalAxis{p.X}
261 glyphs = append(glyphs, xAxis.GlyphBoxes(p)...)
262 r := rightMost(&c, glyphs)
263
264 minx := c.Min.X - l.Min.X
265 maxx := c.Max.X - (r.Min.X + r.Size().X)
266 lx := vg.Length(l.X)
267 rx := vg.Length(r.X)
268 n := (lx*maxx - rx*minx) / (lx - rx)
269 m := ((lx-1)*maxx - rx*minx + minx) / (lx - rx)
270 return draw.Canvas{
271 Canvas: vg.Canvas(c),
272 Rectangle: vg.Rectangle{
273 Min: vg.Point{X: n, Y: c.Min.Y},
274 Max: vg.Point{X: m, Y: c.Max.Y},
275 },
276 }
277}
278
279// rightMost returns the right-most GlyphBox.
280func rightMost(c *draw.Canvas, boxes []GlyphBox) GlyphBox {

Callers 3

DrawMethod · 0.85
DataCanvasMethod · 0.85
DrawGlyphBoxesMethod · 0.85

Calls 6

GlyphBoxesMethod · 0.95
CanvasInterface · 0.92
leftMostFunction · 0.85
rightMostFunction · 0.85
GlyphBoxesMethod · 0.65
SizeMethod · 0.65

Tested by

no test coverage detected