Class pvc.options.axes.CartesianAxis
Extends
pvc.options.panels.Panel.
Constructor Attributes | Constructor Name and Description |
---|---|
<abstract> |
The options documentation class of
the cartesian axis
and cartesian axis panel.
|
Field Attributes | Field Name and Description |
---|---|
Layout | |
The percentage padding,
on each of the sides of the plot panel
that are orthogonal to the axis orientation.
|
|
The position of the axis panel.
|
|
The fixed size of the panel, in pixel units or as a percentage.
|
|
The maximum size of the panel, in pixel units or as a percentage.
|
|
Indicates if the axis panel is shown.
|
|
Style | |
The extension points object contains style definitions for
the marks of the panel.
|
|
The font used by the panel.
|
|
<deprecated> |
Indicates if grid rules are drawn.
|
Indicates if grid rules are drawn
separating discrete values or
at each major continuous tick.
|
|
The axis title and title options.
|
Method Attributes | Method Name and Description |
---|---|
Style | |
tickFormatter(value, precision, index, label)
A tick formatter function.
|
A cartesian axis (and its panel) can be referred to in several ways, in order of precedence:
- By id
- the id of the axis is its type followed by it's index (when >= 2)
- (e.g.: base, ortho, base2, ortho2, ...)
- By oriented id
- the oriented id of the axis is its orientation followed by it's index (when >= 2)
- (e.g.: x, y, x2, y2, ...)
- By legacy name
-
for the special case of the bar chart,
the second axes:
- normal properties — may be referred to by the name second
- extension points — may be referred to by the names secondX and secondY
In any case, those names are now deprecated.
- By scale type
- the scale type can be discrete or continuous and, in the latter case, with higher precedence, numeric and timeSeries are also possible
- By catch all name
- the name axis matches any cartesian axis
These names apply equally to the prefixes used to build extension point names.
Which of the names is used depends on which better selects the axes for the properties being specified. If a property should only be applied to vertical axes, independently of the chart's orientation, the oriented id should be used. If, otherwise, a property should only be applied to the base axis, whether or not it is horizontally aligned, then the normal id should be used. If, a property should only apply to continuous axes, the scale type should be used.
For more information on options that are specific to only certain axis types, please see one of the following concrete sub-classes:
- Numeric-only axes: NumericCartesianAxis
- Normal discrete: FlattenedDiscreteCartesianAxis
- Numeric or time-series: AnyContinuousCartesianAxis
- Normal or hierarchical discrete:: AnyDiscreteCartesianAxis
- Numeric, time-series or normal discrete: AnyNonHierarchicalCartesianAxis
The percentage is a number greater than or equal to 0 and less than 1. It is relative to length of the plot's side that has the same direction as the axis.
The padded area is useful to leave enough free space between the plot's visual elements and the axes panels.
If an axis is horizontal, the padding affects the left and right sides, and if it is vertical, affects the top and bottom sides.
If more than one axis of a given orientation specifies an offset, the maximum specified offset is used.
- Default Value:
- 0
The default value depends on the orientation and index of the axis. For an horizontal axis, it is bottom. For an vertical axis, it is left. For axes other than the first, the default side is the opposite of that of the first axis: top for the horizontal axes and right for the vertical axes.
If a size object is specified, only the component orthogonal to the axis orientation is considered.
See pvc.options.varia.Size for information about the different supported data types.
If a size object is specified, only the component orthogonal to the axis orientation is considered.
See pvc.options.varia.Size for information about the different supported data types.
This property replaces the following (now deprecated) chart properties:
- showXScale
- showYScale
- showSecondScale
- Default Value:
- true
See the supported font format in http://www.w3.org/TR/CSS2/fonts.html#font-shorthand
- Deprecated:
- Use #grid instead.
- Default Value:
- false
- Default Value:
- false
This function has two arguments variants:
- continuous
- tickFormatter(value, precision, index)
- discrete
- tickFormatter(value, label)
Generally, a continuous axis uses the continuous variant and a discrete axis uses the discrete variant.
But, there is one exception to this rule: a discrete axis having a single date dimension, uses the continuous variant. This makes it easier to format date categories, by automatically choosing an adequate precision, that takes the actual data range into account. It's also legacy, version 1, behavior. Use the compatibility flag pvc.options.varia.CompatibilityFlags#discreteTimeSeriesTickFormat to disable this formatting mode.
Summing up:
- a continuous axis uses the continuous arguments variant,
- a discrete axis can use both arguments variant,
- an axis with a single date dimension, uses the continuous arguments variant (if pvc.options.varia.CompatibilityFlags#discreteTimeSeriesTickFormat is true).
Context object
The function is called having as this the ticks array, whose tick values are being formatted.
Together with the index argument, it is possible to use the value of the previous and/or following ticks to format the current tick.
The ticks array provides the following useful properties:
- step — the used precision
- base — the base precision from which step is derived
- mult — the multiple of base precision that yields step (step = base * mult)
- format(v) - the default formatting function
- length — the number of ticks
- Context:
- {Array}
- Arguments:
- {string|number|Date} value
- The value to format.
- continuous arguments variant
- The type of argument value can be number or Date.
- discrete arguments variant
-
The type of argument
value can be
string or
number.
When the axis has a single dimension, argument value is the value of that dimension.
When the axis has more than one dimension, and is flattened, argument value is the junction of the key values of all dimensions, separated by pvc.options.charts.BasicChart#dataSeparator.
When the axis is hierarchical (composite), argument value is the key value of the dimension at a certain level.
- {number} precision Optional
- The precision in which the
value argument should be formatted.
ATTENTION: only present in the continuous arguments variant!
When the axis has a date scale type, the argument is the chosen number of milliseconds between tick values.
The standard time precisions are defined in: pvc.options.varia.TimeInterval.
In general, the given precision is an integer multiple of one the standard precisions. It is many times more useful to use the base standard precision on which the final precision is based on (the value of the context property this.base).
When the axis has a numeric scale type, the argument is the number of decimal places of the chosen step value.
- {number} index Optional
- The index of the tick being formatted.
ATTENTION: only present in the continuous arguments variant!
You may use the index to access neighbouring ticks from the this ticks array (e..g. this[index + 1]).
- {string} label Optional
- The default label.
ATTENTION: only present in the discrete arguments variant!
The default label is the label that would be displayed if the tick formatter had not been specified.
When the axis has a single dimension, argument label is the label as formatted by that dimension.
When the axis has more than one dimension, and is flattened, argument label is the junction of the label values of all dimensions, separated by pvc.options.charts.BasicChart#groupedLabelSep.
When the axis is hierarchical (composite), argument label is the label as formatted by the dimension at a certain level.
- Returns:
- {string} The string that is the formatted value.