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

Method GlyphBoxes

axis.go:309–348  ·  view source on GitHub ↗

GlyphBoxes returns the GlyphBoxes for the tick labels.

(p *Plot)

Source from the content-addressed store, hash-verified

307
308// GlyphBoxes returns the GlyphBoxes for the tick labels.
309func (a horizontalAxis) GlyphBoxes(p *Plot) []GlyphBox {
310 var (
311 boxes []GlyphBox
312 yoff font.Length
313 )
314
315 if a.Label.Text != "" {
316 x := a.Norm(p.X.Max)
317 switch a.Label.Position {
318 case draw.PosCenter:
319 x = a.Norm(0.5 * (p.X.Max + p.X.Min))
320 case draw.PosRight:
321 x -= a.Norm(0.5 * a.Label.TextStyle.Width(a.Label.Text).Points()) // FIXME(sbinet): want data coordinates
322 }
323 descent := a.Label.TextStyle.FontExtents().Descent
324 boxes = append(boxes, GlyphBox{
325 X: x,
326 Rectangle: a.Label.TextStyle.Rectangle(a.Label.Text).Add(vg.Point{Y: yoff + descent}),
327 })
328 yoff += a.Label.TextStyle.Height(a.Label.Text)
329 yoff += a.Label.Padding
330 }
331
332 var (
333 marks = a.Tick.Marker.Ticks(a.Min, a.Max)
334 height = tickLabelHeight(a.Tick.Label, marks)
335 descent = a.Tick.Label.FontExtents().Descent
336 )
337 for _, t := range marks {
338 if t.IsMinor() {
339 continue
340 }
341 box := GlyphBox{
342 X: a.Norm(t.Value),
343 Rectangle: a.Tick.Label.Rectangle(t.Label).Add(vg.Point{Y: yoff + height + descent}),
344 }
345 boxes = append(boxes, box)
346 }
347 return boxes
348}
349
350// A verticalAxis is drawn vertically up the left side of a plot.
351type verticalAxis struct {

Callers 2

DrawGlyphBoxesMethod · 0.95
padXFunction · 0.95

Calls 10

tickLabelHeightFunction · 0.85
NormMethod · 0.80
PointsMethod · 0.80
FontExtentsMethod · 0.80
HeightMethod · 0.80
IsMinorMethod · 0.80
TicksMethod · 0.65
WidthMethod · 0.45
AddMethod · 0.45
RectangleMethod · 0.45

Tested by

no test coverage detected