Plot implements the Plotter interface, drawing a line that connects each point in the Line.
(c draw.Canvas, p *plot.Plot)
| 82 | // Plot implements the Plotter interface, drawing a line |
| 83 | // that connects each point in the Line. |
| 84 | func (h *Histogram) Plot(c draw.Canvas, p *plot.Plot) { |
| 85 | trX, trY := p.Transforms(&c) |
| 86 | |
| 87 | for _, bin := range h.Bins { |
| 88 | ymin := c.Min.Y |
| 89 | ymax := c.Min.Y |
| 90 | if bin.Weight != 0 { |
| 91 | ymax = trY(bin.Weight) |
| 92 | } |
| 93 | xmin := trX(bin.Min) |
| 94 | xmax := trX(bin.Max) |
| 95 | pts := []vg.Point{ |
| 96 | {X: xmin, Y: ymin}, |
| 97 | {X: xmax, Y: ymin}, |
| 98 | {X: xmax, Y: ymax}, |
| 99 | {X: xmin, Y: ymax}, |
| 100 | } |
| 101 | if h.FillColor != nil { |
| 102 | c.FillPolygon(h.FillColor, c.ClipPolygonXY(pts)) |
| 103 | } |
| 104 | pts = append(pts, vg.Point{X: xmin, Y: ymin}) |
| 105 | c.StrokeLines(h.LineStyle, c.ClipLinesXY(pts)...) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | // DataRange returns the minimum and maximum X and Y values |
| 110 | func (h *Histogram) DataRange() (xmin, xmax, ymin, ymax float64) { |
nothing calls this directly
no test coverage detected