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

Method GlyphBoxes

plotter/sankey.go:385–412  ·  view source on GitHub ↗

GlyphBoxes implements the GlyphBoxer interface.

(plt *plot.Plot)

Source from the content-addressed store, hash-verified

383
384// GlyphBoxes implements the GlyphBoxer interface.
385func (s *Sankey) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
386 stocks := s.stockList()
387 boxes := make([]plot.GlyphBox, 0, len(s.flows)+len(stocks))
388
389 for _, stk := range stocks {
390 b1 := plot.GlyphBox{
391 X: plt.X.Norm(float64(stk.category)),
392 Y: plt.Y.Norm((stk.min + stk.max) / 2),
393 Rectangle: vg.Rectangle{
394 Min: vg.Point{X: -s.StockBarWidth / 2},
395 Max: vg.Point{X: s.StockBarWidth / 2},
396 },
397 }
398 label, textStyle, xOff, yOff, _, _ := s.StockStyle(stk.label, stk.category)
399 rect := textStyle.Rectangle(label)
400 rect.Min.X += xOff
401 rect.Max.X += xOff
402 rect.Min.Y += yOff
403 rect.Max.Y += yOff
404 b2 := plot.GlyphBox{
405 X: plt.X.Norm(float64(stk.category)),
406 Y: plt.Y.Norm((stk.min + stk.max) / 2),
407 Rectangle: rect,
408 }
409 boxes = append(boxes, b1, b2)
410 }
411 return boxes
412}
413
414// Thumbnailers creates a group of objects that can be used to
415// add legend entries for the different flow groups in this

Callers

nothing calls this directly

Calls 3

stockListMethod · 0.95
NormMethod · 0.80
RectangleMethod · 0.45

Tested by

no test coverage detected