Thumbnailers creates a group of objects that can be used to add legend entries for the different flow groups in this diagram, as well as the flow group labels that correspond to them.
()
| 415 | // add legend entries for the different flow groups in this |
| 416 | // diagram, as well as the flow group labels that correspond to them. |
| 417 | func (s *Sankey) Thumbnailers() (legendLabels []string, thumbnailers []plot.Thumbnailer) { |
| 418 | type empty struct{} |
| 419 | flowGroups := make(map[string]empty) |
| 420 | for _, f := range s.flows { |
| 421 | flowGroups[f.Group] = empty{} |
| 422 | } |
| 423 | legendLabels = make([]string, len(flowGroups)) |
| 424 | thumbnailers = make([]plot.Thumbnailer, len(flowGroups)) |
| 425 | i := 0 |
| 426 | for g := range flowGroups { |
| 427 | legendLabels[i] = g |
| 428 | i++ |
| 429 | } |
| 430 | sort.Strings(legendLabels) |
| 431 | |
| 432 | for i, g := range legendLabels { |
| 433 | var thmb sankeyFlowThumbnailer |
| 434 | thmb.Color, thmb.LineStyle = s.FlowStyle(g) |
| 435 | thumbnailers[i] = plot.Thumbnailer(thmb) |
| 436 | } |
| 437 | return |
| 438 | } |
| 439 | |
| 440 | // sankeyFlowThumbnailer implements the Thumbnailer interface |
| 441 | // for Sankey flow groups. |