From 7a47e7018ccde09a294789f42534c8c3cbe8a538 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 4 Apr 2018 14:31:47 -0400 Subject: Add X and Y range methods to grid --- grid.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'grid.go') diff --git a/grid.go b/grid.go index d759b75..825fa3b 100644 --- a/grid.go +++ b/grid.go @@ -186,6 +186,24 @@ func (g GridType) Y(dataY float64) float64 { return g.ym*dataY + g.yb } +// XRange returns the minimum and maximum values for the current tickmark +// sequence. These correspond to the data values of the graph's left and right +// edges. +func (g GridType) XRange() (min, max float64) { + min = g.xTicks[0] + max = g.xTicks[len(g.xTicks)-1] + return +} + +// YRange returns the minimum and maximum values for the current tickmark +// sequence. These correspond to the data values of the graph's bottom and top +// edges. +func (g GridType) YRange() (min, max float64) { + min = g.yTicks[0] + max = g.yTicks[len(g.yTicks)-1] + return +} + // TickmarksContainX sets the tickmarks to be shown by Grid() in the horizontal // dimension. The argument min and max specify the minimum and maximum values // to be contained within the grid. The tickmark values that are generated are -- cgit v1.2.1-24-ge1ad