GridLines is a strategy object that implements a general strategy for finding a suitable min max range for graphing and suitable intervals for grid lines and labelling.
The object that does the actual drawing on a view is DrawGrid.
A GridLines object uses a ControlSpec to define the minimum and maximum possible values. Given a data set's actual minimum and maximum values, the GridLines object can choose a logical range for graphing that encompasses the data that will be plotted.
Future development work will add subclasses of GridLines that can bind more tightly with the data they are representing. For instance a FreqGridLines (not yet implemented) could apply stronger lines to octave divisions. A DegreeGridLines could be used to draw pitch degree gridlines behind a frequency plot.
Spec has a .grid variable that points to its preferred GridLines object that should be used for graphing.
This default implementation does not know anything about the data is displaying:
A MidinoteGrid could be written that labels these correctly, shows octaves and individual notes depending on the current zoom.
Note that the GridLines does not know which axis it is to be used on and could also be used in polar plots or in 3D rendering.
spec |
The ControlSpec that defines the mininum and maximum values, warn and step. |
a GridLines
get/set the spec
a ControlSpec
return self. nil.asGrid would return a BlankGridLines which is a subclass of GridLines. So when plotting if you specify a grid of nil then you will get no lines at all.
self
Based on: http://books.google.de/books?id=fvA7zLEFWZgC&pg=PA61&lpg=PA61This rounds a value to a logical nice number. It is mostly used to support internal calculation, though it may be useful for other applications.
val |
The value. |
round |
Boolean. Rounding uses a specific algorithm. This is not simple rounding to an integer value. |
the nice number
for internal use
min |
(describe argument here) |
max |
(describe argument here) |
ntick |
(describe argument here) |
(returnvalue)
Returns the logical minimum and maximum that will contain the data.
min |
minimum value |
max |
maximum value. |
ntick |
the number of lines you would like (which usually varies by how much screen space you have and what you consider cluttered) |
[ideal min, ideal max]
Specifically for use by DrawGrid. This returns a dictionary filled with: 'lines': an array of values where lines should be drawn 'labels': [value, formatted label] for each line
valueMin |
minimum value of the data to be plotted |
valueMax |
maximum value of the data to be plotted |
pixelMin |
If numTicks is nil: used to guess the ideal numTicks based on the graph size. |
pixelMax |
If numTicks is nil: used to guess the ideal numTicks based on the graph size. |
numTicks |
Explicit number of ticks you would like to see on the graph. |
A dictionary
Round the value and append the spec's units
val |
The value |
numDecimalPlaces |
Number of decimal places |
a string