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

Method Thumbnailers

plotter/sankey.go:417–438  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

415// add legend entries for the different flow groups in this
416// diagram, as well as the flow group labels that correspond to them.
417func (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.

Callers 1

ExampleSankey_groupedFunction · 0.95

Calls 1

ThumbnailerInterface · 0.92

Tested by 1

ExampleSankey_groupedFunction · 0.76