OutsideLabels returns a *Labels that will plot a label for each of the outside points. The labels are assumed to correspond to the points used to create the box plot.
(labels Labeller)
| 287 | // labels are assumed to correspond to the |
| 288 | // points used to create the box plot. |
| 289 | func (b *BoxPlot) OutsideLabels(labels Labeller) (*Labels, error) { |
| 290 | if b.Horizontal { |
| 291 | b := &horizBoxPlot{b} |
| 292 | return b.OutsideLabels(labels) |
| 293 | } |
| 294 | |
| 295 | strs := make([]string, len(b.Outside)) |
| 296 | for i, out := range b.Outside { |
| 297 | strs[i] = labels.Label(out) |
| 298 | } |
| 299 | o := boxPlotOutsideLabels{b, strs} |
| 300 | ls, err := NewLabels(o) |
| 301 | if err != nil { |
| 302 | return nil, err |
| 303 | } |
| 304 | off := 0.5 * b.GlyphStyle.Radius |
| 305 | ls.Offset = ls.Offset.Add(vg.Point{X: off, Y: off}) |
| 306 | return ls, nil |
| 307 | } |
| 308 | |
| 309 | type boxPlotOutsideLabels struct { |
| 310 | box *BoxPlot |