Plot implements the plot.Plotter interface.
(c draw.Canvas, plt *plot.Plot)
| 41 | |
| 42 | // Plot implements the plot.Plotter interface. |
| 43 | func (g *Grid) Plot(c draw.Canvas, plt *plot.Plot) { |
| 44 | trX, trY := plt.Transforms(&c) |
| 45 | |
| 46 | var ( |
| 47 | ymin = c.Min.Y |
| 48 | ymax = c.Max.Y |
| 49 | xmin = c.Min.X |
| 50 | xmax = c.Max.X |
| 51 | ) |
| 52 | |
| 53 | if g.Vertical.Color == nil { |
| 54 | goto horiz |
| 55 | } |
| 56 | for _, tk := range plt.X.Tick.Marker.Ticks(plt.X.Min, plt.X.Max) { |
| 57 | if tk.IsMinor() { |
| 58 | continue |
| 59 | } |
| 60 | x := trX(tk.Value) |
| 61 | if x > xmax || x < xmin { |
| 62 | continue |
| 63 | } |
| 64 | c.StrokeLine2(g.Vertical, x, ymin, x, ymax) |
| 65 | } |
| 66 | |
| 67 | horiz: |
| 68 | if g.Horizontal.Color == nil { |
| 69 | return |
| 70 | } |
| 71 | for _, tk := range plt.Y.Tick.Marker.Ticks(plt.Y.Min, plt.Y.Max) { |
| 72 | if tk.IsMinor() { |
| 73 | continue |
| 74 | } |
| 75 | y := trY(tk.Value) |
| 76 | if y > ymax || y < ymin { |
| 77 | continue |
| 78 | } |
| 79 | c.StrokeLine2(g.Horizontal, xmin, y, xmax, y) |
| 80 | } |
| 81 | } |
nothing calls this directly
no test coverage detected