ExponentialGridLines
is a strategy object that finds suitable intervals for plotting grid lines and labels. The values span the range defined by a corresponding ControlSpec. Most of the functionality of ExponentialGridLines
is inherited from its superclass, AbstractGridLines. The instance methods are used by DrawGrid (which is in turn used by Plotter) which handles the drawing of the lines and labels.
ExponentialGridLines
isn't usually instantiated directly, but rather by the GridLines factory class or the ControlSpec: -grid method which return the appropriate AbstractGridLines
subclass for the given spec.
spec |
A ControlSpec that defines the numerical range, warp, and step. |
An instance of this class.
AbstractGridLines
shouldn't be instantiated directly. Instead, the GridLines factory class or the ControlSpec: -grid method should be used to return the appropriate AbstractGridLines
subclass.Return this object.
nil.asGrid
returns a BlankGridLines
(a subclass of AbstractGridLines
) which produces no drawn lines. So if nil
is passed to the grid argument of DrawGrid
, no lines are drawn on the corresponding axis.
Rounds a value to a logical "nice number" that is within the same order of magnitude. See the discussion below for details.
val |
The value you'd like to make nicer. |
round |
A boolean. Roughly speaking, rounding will allow the returned number to be above or below the input val (similar to a |
The nice number.
This method is used to support internal calculations for determining grid line values, though it may be useful for other applications.
Observe the rounding behavior:
The implementation is based on: A. S. Glassner, Ed., Graphics Gems. San Diego: Morgan Kaufmann, 1990.
Returns the logical minimum and maximum that will contain the min and max, determed internally using -niceNum.
min |
Minimum value to include in the returned range. |
max |
Maximum value to include in the returned range. |
ntick |
The number of lines ("ticks") you would like within the range of |
An Array with the lower and upper bounds of the range containing your min and max, i.e. [rangeMin, rangeMax]
.
Specifically for use by DrawGrid. This returns a Dictionary with keys: 'lines'
, an array of values where lines should be drawn, and 'labels'
, an array of 2-element arrays [value, "formatted label"]
for each line.
Note that the highest and lowest values returned don't necessarily contain your valueMin and valueMax, but rather represent the values where grid lines will be drawn by DrawGrid
(endcap lines are subsequently drawn at the data/grid bounds).
valueMin |
Minimum value of the data to be plotted. The lowest grid line value returned may be higher than this value. |
valueMax |
Maximum value of the data to be plotted. The highest grid line value returned may be lower than this value. |
pixelMin |
Lower bound of the grid's range, in pixels. Used to calculate the size of the available grid space when determining grid values based on tickSpacing (if numTicks is |
pixelMax |
Upper bound of the grid's range, in pixels. Used to calculate the size of the available grid space when determining grid values based on tickSpacing (if numTicks is |
numTicks |
Explicit number of ticks you would like to see on the graph (though the result is approximate). Set to |
tickSpacing |
Minimum distance between ticks (in pixels). This value is only used when numTicks is |
A Dictionary.
Format a numerical value for display as text, rounded to a desired precision.
val |
The value to round and convert to a text label. |
numDecimalPlaces |
Number of decimal places to represent in the returned |
A String.