GlyphBoxes implements the GlyphBoxer interface.
(plt *plot.Plot)
| 383 | |
| 384 | // GlyphBoxes implements the GlyphBoxer interface. |
| 385 | func (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 |