Axis class

The purpose of this class is to draw the axes supplementing the graphical representation of 1D or 2D array data. A graphical representation of a 1D array is provided by the class Polyline of this package. For 1D arrays, a horizontal coordinate axis and a vertical intensity axis is provided (constructors Axis.coord and Axis.intens. For 2D arrays, a horizontal coordinate axis and a vertical second coordinate axis is provided (both constructed with Axis.coord. The user can control many axis attributes. Note: Drawing is performed using Svg, Scalable Vector Graphics. Usage:

  1. Construct an axis: axis = Axis.coord(args) or Axis.intens(args).
  2. The axis was drawn into the SvgSvgElement labelsContainer using Svg.
  3. Set the desired position of labelsContainer by setting its "x" and "y" Svg attributes. For convenience, do it with SVG.setAttr(). x and y must be relative to the container in which labelsContainer will be embedded (plotArea in next step 4).
  4. Append labelsContainer to the desired SvgSvgElement type container of your particluar page layout: plotArea.append(axis.labelsContainer)

Constructors

Axis(int npoints, double start, double end, double physStart, double physWidth, bool center, double calib, double _coordShift, int axisLength, int axisWidth, int gridLength, PhysicalToScreen physToScreen, Map<AxA, String> axesAttributes, List<TouchCallback> touchCallbacks)
Constructs an axis. See Axis.coord and Axis.intens for a description of the arguments. Use these named constructors rather than this one.
Axis.coord(int npoints, double ixFirst, double ixLast, double physStart, double physWidth, bool center, double calib, int axisLength, int axisAreaWidth, int gridLength, PhysicalToScreen physToScreen, Map<AxA, String> axesAttributes, List<TouchCallback> touchCallbacks)
Creates a coordinate axis for data represented by an array. The axis consists of the following axis elements: axis ticks, axis labels, axis legend and grid lines. No straight line representing the axis itself is drawn. This is very simple and is left to the caller for flexibility reasons. [...]
Axis.intens(double start, double end, double refval, double refvalNormalized, double coordShift, int axisLength, int axisAreaWidth, int gridLength, PhysicalToScreen physToScreen, Map<AxA, String> axesAttributes, List<TouchCallback> touchCallbacks)
Creates a vertical intensity axis. See the other constructors for a horizontal or vertical coordinate axis. start, end: Only those axis ticks, text labels, and grid lines lying in this y intensity range will be drawn. [...]

Properties

extra_space_for_edge_labels_x ↔ int
Corresponds to the attribute EXTRA_SPACE_FOR_EDGE_LABELS_X. It is needed for the case where a coordinate value label is drawn exactly at the left or right of the x axis. The tick position is then 0 or axisWidth in labelsContainer coordinates. We will draw the text labels into the same container. Since the labels are centered around the ticks, half of such a label would lie outside the container an would be clipped. Using EXTRA_SPACE_FOR_EDGE_LABELS_X, we extend the container so as to make such a label fully visible.
read / write
extra_space_for_edge_labels_y ↔ int
Accordingly for y axis.
read / write
labelsContainer ↔ SvgSvgElement
The axis is drawn into this container by the constructor. You will have to place it according to your desired app layout to make it visible in your app.
read / write
physToScreen PhysicalToScreen
read / write
xyGrid XYGrid
This is the coordinate grid which can be drawn optionally. The grid graph is contained in xyGrid.gridContainer. You will have to place it according to your desired app layout to make it visible.
read / write
hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

getScreenPos(double physcoord) → int
Returns the screen position of physcoord for this axis relative to the data area. Accounts for reversed axis and for axis calibrationFactor.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited

Static Properties

AXIS_DEFAULT_ATTRIBUTES → Map<AxA, String>
Default attributes for axes and grid.
final

Static Methods

genLabels(double left, double right, { bool tightStyle: true, int nticks: 5, int scale }) → List<String>
Generates nice axis labels for a graph and return them as a list of Strings. From https://github.com/alexreisner/smart_chart/blob/master/lib/smart_chart/vendor/nice_numbers.rb [...]
nicenum(double x, bool round) → double
Finds a "nice" number (1, 2, 5, or power-or-ten multiple thereof) approximately equal to x. Rounds the number if round = true, takes ceiling if round = false.