ChartAxis (class)
public abstract ChartAxis {inherits ShapeGroup}
Package: CURL.GUI.CHARTS
Direct Known Subclasses: NumericAxis-of, DataSeriesAxis, DefaultChartAxis, DefaultBarChartAxis

An abstract class representing an axis within a LayeredChart.

Description

ChartAxis objects define the manner in which the plot area of a LayeredChart is measured. They provide a two-way mapping from data to spatial coordinates. This mapping is implemented in ChartAxis.get-position and ChartAxis.get-value, although you will be more likely to use ChartDataMapping and ChartInverseDataMapping through ChartLayer.get-data-mapping and ChartLayer.get-inverse-data-mapping, respectively. These objects essentially wrap axis matching logic and calls to ChartAxis.get-position and ChartAxis.get-value.

ChartAxis is designed to be user-subclassable, but there are usually easier ways to customize the behavior of an axis. The following options are supported for ChartAxis, or for some subset of the ChartAxis classes:



The supplied implementations of ChartAxis are:



You can use the default ChartAxis factory to create an axis of the appropriate type for one or more ChartDataSeries. See ChartAxis.default#factory for more details.

Some of the functionality pertaining to label generation and spacing are delegated to ChartAxis.label-group; see ChartLabelGroup for information on how to affect label generation and positioning.

Notes

LayeredChart will attempt to automatically create appropriate X and Y axis for its contents, based on ChartLayer.x-axis-data and ChartLayer.y-axis-data. However, in some circumstances, you may wish to create your own axis object directly. See LayeredChart for more information about the automatic axis generation process.

The Shape hierarchy of a ChartAxis is as follows:


Constructors
default:Initialize a new ChartAxis class.
constructor protected {ChartAxis.default
    label-group:ChartLabelGroup = {ChartLabelGroup},
    axis-group:Shape = {ShapeGroup},
    axis-line-group:Shape = {ShapeGroup},
    major-tick-group:Shape = {ShapeGroup},
    minor-tick-group:Shape = {ShapeGroup},
    ...
}
default:Create a ChartAxis based on one or more ChartDataSeries.
factory public {ChartAxis.default data:ChartDataSeries, ...}:ChartAxis
Properties
axis-group:The Shape parent of the axis and tick Shapes.
field public constant ChartAxis.axis-group:Shape
axis-label:The label or label factory for this ChartAxis.
nonlocal option public ChartAxis.axis-label:any
axis-line-group:The Shape parent of the axis line Shape.
field public constant ChartAxis.axis-line-group:Shape
chart:The LayeredChart, if any, that contains this ChartAxis.
field public-get private-set ChartAxis.chart:#LayeredChart
label-group:The ChartLabelGroup responsible for containing and positioning the labels associated with this axis.
field public constant ChartAxis.label-group:ChartLabelGroup
length:The length of this axis.
field public-get private-set ChartAxis.length:Distance
major-tick-factory:A factory procedure for the generation of ticks within this ChartAxis.
nonlocal option public ChartAxis.major-tick-factory:#TickFactory
major-tick-group:The Shape parent of the major tick Shapes for this axis.
field public constant ChartAxis.major-tick-group:Shape
minor-tick-factory:A factory procedure for the generation of ticks within this ChartAxis.
nonlocal option public ChartAxis.minor-tick-factory:#TickFactory
minor-tick-group:The Shape parent of the minor tick Shapes for this axis.
field public constant ChartAxis.minor-tick-group:Shape
position:The position of this axis within the LayeredChart, as defined by AxisPosition.
field public-get private-set ChartAxis.position:AxisPosition =AxisPosition.none
style-element:The "element" or "type" of this Visual, for the purpose of styling.
accessor public ChartAxis.style-element:String
tick-label-factory:A factory procedure for the generation of tick labels within this ChartAxis.
nonlocal option public ChartAxis.tick-label-factory:TickLabelFactory
x-axis?:true if this axis is currently in use as an X axis within a LayeredChart.
accessor public final ChartAxis.x-axis?:bool
y-axis?:true if this axis is currently in use as an Y axis within a LayeredChart.
accessor public final ChartAxis.y-axis?:bool
Properties inherited from Shape: as-Shape, border-color, color, draw-operation, option-parent, selection-context, shape-parent, shape-selectable, stroke-thickness, transformation, visible?
Properties inherited from ShapeContainerBase: as-ShapeRoot, shape-children
Properties inherited from Visual: _style-element, clonable-class?, completely-clonable-children?, cursor, data-source, display-context, dragee, font-size, input-method-enabled?, input-method-keyboard-mode, name, options, options-present-here, style-class, style-manager, style-options, test-description, test-name, test-parent?, test-type-name, test-visible?, tooltip, user-data
Properties inherited from DataBindingTarget: data-binding-context, data-bindings
Properties inherited from EventTarget: event-handlers
Properties inherited from OptionListInterface: option-register-proc, registered-option-keys
Methods
clear-shapes:Clear the Shape contents of this axis.
public {ChartAxis.clear-shapes}:void
detach:Detach this shape from its parent.
public {ChartAxis.detach}:void
generate-axis-label:Generate an axis label appropriate for this ChartAxis.
public abstract {ChartAxis.generate-axis-label}:#Shape
generate-axis-line:Generate the Shape or Shapes required to represent the axis line for this axis.
protected {ChartAxis.generate-axis-line}:void
generate-major-tick:Generate a Shape representing a major tick.
public {ChartAxis.generate-major-tick
    value:any,
    tick-index:int,
    position:Distance = {self.get-position value}
}:Shape
generate-major-ticks:Generate all Shapes required to represent the major ticks along this axis.
protected abstract {ChartAxis.generate-major-ticks}:void
generate-minor-tick:Generate a Shape representing a minor tick.
public {ChartAxis.generate-minor-tick
    value:any,
    tick-index:int,
    position:Distance = {self.get-position value}
}:Shape
generate-minor-ticks:Generate all Shapes required to represent the minor ticks along this axis.
protected abstract {ChartAxis.generate-minor-ticks}:void
generate-tick-label:Generate a tick label for the given tick.
public {ChartAxis.generate-tick-label
    tick:ChartTick,
    tick-rotation:Angle
}:#Shape
get-axis-label:Create a Shape appropriate for use as the label for this axis.
public final {ChartAxis.get-axis-label}:#Shape
get-data-type:Describes the way in which a ChartAxis is defined.
public abstract {ChartAxis.get-data-type
}:(type:AxisDataType, value:any)
get-major-ticks-Iterator:Returns an Iterator-of useful for iterating through the ticks in this axis.
public {ChartAxis.get-major-ticks-Iterator}:{Iterator-of ChartTick}
get-minor-ticks-Iterator:Returns an Iterator-of useful for iterating through the ticks in this axis.
public {ChartAxis.get-minor-ticks-Iterator}:{Iterator-of ChartTick}
get-position:Calculate the spatial position corresponding to a data value.
public {ChartAxis.get-position value:any}:Distance
get-position-at-zero:Get the spatial position along this axis corresponding with zero.
public abstract {ChartAxis.get-position-at-zero}:Distance
get-relative-position:Calculate the spatial position corresponding to a data value.
public abstract {ChartAxis.get-relative-position value:any}:Fraction
get-tick-label:Create a Shape appropriate for use as the label for a tick.
public final {ChartAxis.get-tick-label
    tick:ChartTick,
    tick-rotation:Angle
}:#Shape
get-tick-label-alignment:Retrieve the default alignment for tick labels.
public {ChartAxis.get-tick-label-alignment
    rotation:Angle
}:(halign:String, valign:String)
get-value:Calculate the data value that corresponds with a position along this axis.
public {ChartAxis.get-value position:Distance}:any
get-value-relative:Calculate the data value that corresponds with a position along this axis.
public abstract {ChartAxis.get-value-relative position:Fraction}:any
note-min-max-computation-changed:Notifies this ChartAxis of a change in some factor affecting the values returned by LayeredChart.compute-data-min-max.
public {ChartAxis.note-min-max-computation-changed}:void
regenerate-shapes:Create all Shape objects required to represent this axis.
public {ChartAxis.regenerate-shapes}:void
transform-from-chart:Transforms a point from the LayeredChart's coordinate system into that of this ChartAxis.
public {ChartAxis.transform-from-chart point:Distance2d}:Distance2d
transform-to-chart:Transforms a point from this ChartAxis' local coordinate system to that of the containing LayeredChart.
public {ChartAxis.transform-to-chart point:Distance2d}:Distance2d
update-layout:Perform all required layout operations for the axis.
public {ChartAxis.update-layout length:Distance}:void
Methods inherited from ShapeGroup: draw, get-own-bounds, get-own-bounds-in-shape-root, self-contains-point?, self-intersects-polygon?
Methods inherited from Shape: apply-rotation, apply-scale, apply-transformation, apply-translation, apply-translation-in-parent, constrain-own-layout-bounds, constrain-shape-layout-bounds, contains-point?, find-graphical-ancestor, fire-crossing-event, fire-in-child, get-display-context, get-down-orientation-in-shape-parent, get-graphical-root, get-local-device-pixel-size, get-origin-in-graphical-ancestor, get-origin-in-root, get-origin-in-shape-parent, get-origin-in-shape-root, get-own-layout-bounds, get-right-orientation-in-shape-parent, get-shape-bounds, get-shape-bounds-in-shape-root, get-shape-layout-bounds, get-top-left-in-ancestor, get-transformation-to-shape-root, keyword-init-arg, option-change-notify, overdraw-for-selection, quantize-line-thickness, request-draw, request-draw-self, reset-transformation, set-rotation, set-scale, set-transformation, set-translation-in-parent, to-Graphic, transform-from-display-coordinates, transform-from-graphical-root-coordinates, transform-point-from-shape-root, transform-point-to-shape-root, transform-to-display-coordinates, transform-to-graphical-root-coordinates, transform-vector-from-shape-root, transform-vector-to-shape-root, transformation-changed, transformation-changing
Methods inherited from ShapeContainerBase: add, clear, draw-shape-child, draw-shape-children, get-all-children-at-point, get-child-at-point, get-leaf-at-point, get-shape-root, note-attached, note-detaching, notify-option-children, on-drag-enter, on-pointer-enter, on-pointer-envelope-event, register-options, remove, set-shape-index, set-shape-index-after, set-shape-index-before, shape-container-fire-inferior-crossing-event, shape-container-handle-crossing, shape-container-pick-child, shape-container-pointer-enter-occurred, shape-container-pointer-leave-occurred
Methods inherited from Visual: add-from-init-args, add-option, add-style-option, animate, change-cursor, clonable-appearance?, clone-appearance, clone-appearance-helper, find-test-children, get-focus-manager, get-layout-context, get-test-parent, get-test-property, get-text, get-view, maybe-fire-attach-event, maybe-fire-detach-event, non-keyword-init-arg, note-caret-position, on-drag-leave, on-pointer-leave, pop-cursor, prepare-test-object, prepare-test-parent, push-cursor, quantize-width, release-key-focus, remove-option, remove-style-option, request-key-focus, scroll-to-include, test-record, test-run, xy-offset-to
Methods inherited from GraphicOptions: any-to-Distance
Methods inherited from GuiEventTarget: handle-event, on-action, on-cancel-mode, on-command-changed, on-commit, on-composition-change-event, on-composition-result-event, on-context-menu-event, on-current-record-change-request, on-current-record-changed, on-destroy-notify, on-destroy-requested, on-drag-over, on-drag-pointer, on-drag-started, on-drop, on-end-composition-event, on-focus-event, on-focus-in, on-focus-out, on-grab-release, on-gui-event, on-input-method-event, on-inspection, on-key-event, on-key-press, on-pointer-button, on-pointer-crossing, on-pointer-event, on-pointer-motion, on-pointer-press, on-pointer-release, on-pointer-scroll, on-raw-key-event, on-raw-key-press, on-raw-key-release, on-reset, on-selectable-added, on-selectable-removed, on-selection-changed, on-selection-context-activated, on-selection-context-deactivated, on-selection-event, on-start-composition-event, on-start-event, on-stop-event, on-view-activate, on-view-deactivate, on-window-close, remove-event-handlers-for-event-class
Methods inherited from DataBindingTarget: add-data-binding, get-data-binding, refresh-data-binding, remove-data-binding, unset-property, update-data-binding, validate-data-binding
Methods inherited from EventTarget: accepts-event-class?, add-event-handler, event-handler-present?, remove-event-handler, verify-event
Methods inherited from OptionListInterface: change-option-parent-notify, clone-options, get-option, get-option-by-name, local-add-notify, local-remove-notify, name-to-option-key, new-option-item, option-changed, option-lookup, option-lookup-here, option-propagate-notify, option-set?, propagate-option-change, remove-styles, set-option-by-name, set-style-option-by-name, unset-option-by-name, unset-style-option-by-name
Methods inherited from BasicEventTarget: enqueue-event
Methods inherited from InitRestArgParser: process-rest-args
Methods inherited from Object: object-describe, object-describe-for-debugging, object-serialize

Constructor Details
default (constructor)
protected {ChartAxis.default
    label-group:ChartLabelGroup = {ChartLabelGroup},
    axis-group:Shape = {ShapeGroup},
    axis-line-group:Shape = {ShapeGroup},
    major-tick-group:Shape = {ShapeGroup},
    minor-tick-group:Shape = {ShapeGroup},
    ...
}

Initialize a new ChartAxis class.

label-group: The initial value for ChartAxis.label-group.
axis-group: The initial value for ChartAxis.axis-group.
axis-line-group: The initial value for ChartAxis.axis-line-group.
major-tick-group: The initial value for ChartAxis.major-tick-group.
minor-tick-group: The initial value for ChartAxis.minor-tick-group.
...: Any of the arguments that Shape accepts. These are primarily keyword arguments representing option initializations.

Description

Since ChartAxis is abstract, only subclasses need to call this constructor. If you wish to create a ChartAxis subclass automatically based on data, see ChartAxis.default#factory.


default (factory)
public {ChartAxis.default data:ChartDataSeries, ...}:ChartAxis

Create a ChartAxis based on one or more ChartDataSeries.

data: The first ChartDataSeries to be added to the ChartAxis created.
...: The rest arguments may consist of additional ChartDataSeries to be added to the axis and initialization parameters for the ChartAxis created; see ChartAxis.default.

Returns

, A ChartAxis appropriate for the data provided.

Description

This factory examines the type of data present in data and constructs the a subclass of ChartAxis appropriate for that data type. The types that may be created are:

Example

See ChartAxis.axis-group.


Property Details
axis-group (field)
public constant ChartAxis.axis-group:Shape

The Shape parent of the axis and tick Shapes.

Description

This object exists strictly for convenience; you can use it to set options that will affect all of its children, for instance. See ChartAxis for an explanation of the ChartAxis Shape hierarchy.

Example

The following example combines several interesting techniques. It creates axes using the default ChartAxis factory, providing its own ShapeGroup objects for ChartAxis.axis-group. It then creates a LineLayer. The example places event handlers on LineLayer.series-shapes that change the color of the axis groups created earlier; it uses the ChartLayoutChanged event to receive notification of when the contents of LineLayer.series-shapes have changed.

The net effect is that, when you move the pointer over one of the plotted shapes, the Y axis for that plot is highlighted in red.


Example: Using ChartAxis.axis-group to change the axis and tick color
{import * from CURL.GUI.CHARTS}
{import * from CHARTS-DOC,
    location = "../docstring-support/gui/charts-doc.scurl"
}

{let left-group:ShapeGroup =
    {ShapeGroup
        color = FillPattern.black
    }
}

{let right-group:ShapeGroup =
    {ShapeGroup
        color = FillPattern.black
    }
}

{LayeredChart
    width = 15cm,
    height = 7cm,
    left-axis =
        {ChartAxis
            {ChartDataSeries sample-records, "Age"},
            axis-group = left-group
        },
    right-axis =
        {ChartAxis
            {ChartDataSeries sample-records, "Wins"},
            axis-group = right-group
        },
    {LineLayer
        sample-records,
        "Age",
        "Wins",
        x-axis-data =
            {ChartDataSeries sample-records, "Name"},
        stroke-thickness = 2pt,
        {on ChartLayoutChanged at layer:LineLayer do
            || Assume that there are two data
            || series, and that they correspond
            || to the left and right axes,
            || respectively.
            {layer.series-shapes[0].add-event-handler
                {on PointerEnter do
                    set left-group.color = FillPattern.red
                }
            }
            {layer.series-shapes[0].add-event-handler
                {on PointerLeave do
                    set left-group.color = FillPattern.black
                }
            }
            {layer.series-shapes[1].add-event-handler
                {on PointerEnter do
                    set right-group.color = FillPattern.red
                }
            }
            {layer.series-shapes[1].add-event-handler
                {on PointerLeave do
                    set right-group.color = FillPattern.black
                }
            }
        }
    }
}


axis-label (nonlocal option)
public ChartAxis.axis-label:any

The label or label factory for this ChartAxis.

Description

See axis-label.


axis-line-group (field)
public constant ChartAxis.axis-line-group:Shape

The Shape parent of the axis line Shape.

Description

This object exists strictly for convenience; you can use it to set options that will affect all of its children, for instance. See ChartAxis for an explanation of the ChartAxis Shape hierarchy.

Notes

See ChartAxis.axis-group for an example of using a similar object.


chart (field)
public-get private-set ChartAxis.chart:#LayeredChart

The LayeredChart, if any, that contains this ChartAxis.

Description

This property is set as soon as the ChartAxis is added to the LayeredChart.


label-group (field)
public constant ChartAxis.label-group:ChartLabelGroup

The ChartLabelGroup responsible for containing and positioning the labels associated with this axis.

Description

This object is the Shape parent for all tick labels and the axis label associated with this ChartAxis. It is responsible for performing the actual calls required to generate labels (ChartAxis.get-tick-label and ChartAxis.get-axis-label) and for placing the results at the correct position and orientation.


length (field)
public-get private-set ChartAxis.length:Distance

The length of this axis.

Description

This value is always positive, even though increasing data values generally correspond with decreasing positions for vertical axes.

Notes

This value is updated during calls to ChartAxis.update-layout, itself called from LayeredChart.update-layout.


major-tick-factory (nonlocal option)
public ChartAxis.major-tick-factory:#TickFactory

A factory procedure for the generation of ticks within this ChartAxis.

Description

See major-tick-factory.


major-tick-group (field)
public constant ChartAxis.major-tick-group:Shape

The Shape parent of the major tick Shapes for this axis.

Description

This object exists strictly for convenience; you can use it to set options that will affect all of its children, for instance. See ChartAxis for an explanation of the ChartAxis Shape hierarchy.

Notes

See ChartAxis.axis-group for an example of using a similar object. If that example had used this object instead of axis-group, then only the ticks would have changed colors.


minor-tick-factory (nonlocal option)
public ChartAxis.minor-tick-factory:#TickFactory

A factory procedure for the generation of ticks within this ChartAxis.

Description

See minor-tick-factory.


minor-tick-group (field)
public constant ChartAxis.minor-tick-group:Shape

The Shape parent of the minor tick Shapes for this axis.

Description

This object exists strictly for convenience; you can use it to set options that will affect all of its children, for instance. See ChartAxis for an explanation of the ChartAxis Shape hierarchy.

Notes

See ChartAxis.axis-group for an example of using a similar object.

Minor ticks are not created by default; to create them, you must create your own subclass of ChartAxis or one of its implementations, and override ChartAxis.generate-minor-ticks.


position (field)
public-get private-set ChartAxis.position:AxisPosition =AxisPosition.none

The position of this axis within the LayeredChart, as defined by AxisPosition.

Notes

This value is updated during calls to ChartAxis.update-layout, itself called from LayeredChart.update-layout.


style-element (accessor)
accessor public ChartAxis.style-element:String

The "element" or "type" of this Visual, for the purpose of styling.

Description

This implementation returns the value of Visual._style-element but is normally overridden to return a constant value.

Overriding

If a subclass of Visual should be stylable separately from other types of objects, this getter should be overridden to return an appropriate string. By convention, this string is the name of the class or the name of the markup that produces the object.

An override must return self._style-element if it is not the empty string.
Introduced in: version 6.0


tick-label-factory (nonlocal option)
public ChartAxis.tick-label-factory:TickLabelFactory

A factory procedure for the generation of tick labels within this ChartAxis.

Description

See tick-label-factory.


x-axis? (accessor)
accessor public final ChartAxis.x-axis?:bool

true if this axis is currently in use as an X axis within a LayeredChart.



y-axis? (accessor)
accessor public final ChartAxis.y-axis?:bool

true if this axis is currently in use as an Y axis within a LayeredChart.



Method Details
clear-shapes (method)
public {ChartAxis.clear-shapes}:void

Clear the Shape contents of this axis.

Description

This does not remove the Shape children of the axis. Instead, it clears the following objects of their Shape children:

Notes

This method is only intended to be called from within ChartAxis itself. Specifically, ChartAxis.regenerate-shapes calls this method.

While you should never need to call this method, it may be useful to override it in a subclass to receive notification of when the clearing occurs.


detach (method)
public {ChartAxis.detach}:void

Detach this shape from its parent.

Description

This is semantically equivalent to calling ShapeContainerBase.remove on this shape's parent.

Calling detach on a shape with no parent has no effect.


generate-axis-label (method)
public abstract {ChartAxis.generate-axis-label}:#Shape

Generate an axis label appropriate for this ChartAxis.

Returns

A Shape representing the label, or null if no label should be displayed.

Description

ChartAxis subclasses must define this method. You may also wish to override this method if you are subclassing an existing ChartAxis class. See ChartAxis.get-axis-label for a more complete discussion of controlling the appearance of the axis label.

The Shape created need not be rotated or positioned, as ChartLabelGroup will set its position and rotation directly as appropriate to the axis' position. If you wish to specify an offset with respect to that position, you can apply the desired transformation to the label shape and then embed it within a ShapeGroup. The ShapeGroup will be the object that is positioned by ChartLabelGroup, and the child Shape you embedded will be brought along with it. See axis-label for an example that demonstrates this using scaling.

You must take care that the object generated is positioned well with respect to its origin. The origin will be placed in alignment with the center of the axis, close to the axis itself, and the rotation of the object will be 0 degrees or -90 degrees for the horizontal and vertical axes, respectively. For these reasons, you will need to position the shape you generate carefully to ensure it is where you want it to be (rather than, for instance, overlapping the axis and ticks).

See axis-label for a discussion of how to ensure this using options like halign or horigin on objects like TextShape.

Notes

This is usually implemented to depend on the data controlling the axis. For instance, DataSeriesAxis and subclasses return a TextShape containing the RecordField.caption value for all RecordFields they contain.


generate-axis-line (method)
protected {ChartAxis.generate-axis-line}:void

Generate the Shape or Shapes required to represent the axis line for this axis.

Description

You can override this method in ChartAxis subclasses to modify the manner in which the axis line is generated. By default, this method generates a AxisLineShape.

Generated objects should be added to ChartAxis.axis-line-group. The origin of these objects will coincide with the origin of the axis itself.


generate-major-tick (method)
public {ChartAxis.generate-major-tick
    value:any,
    tick-index:int,
    position:Distance = {self.get-position value}
}:Shape

Generate a Shape representing a major tick.

value: The data value representing this tick. This may be passed to ChartAxis.get-position and used as ChartTick.value
tick-index: The zero-based index of this tick. This can be useful for features such as changing the color of alternating ticks.
position: The position along the axis at which the tick is to be placed. By default, ChartAxis.get-position is called using value to get the correct position. You only need pass a value using position if you have already calculated it; this is an optimization only.

Returns

A Shape representing the tick.

Description

This method is commonly called by implementations of ChartAxis.generate-major-ticks to create the required ticks.

It is implemented to call the value of major-tick-factory, if any; otherwise, it creates a MajorTickShape. Regardless of its source, the resulting Shape is added to ChartAxis.major-tick-group, and returned.

Notes

Unless you are subclassing ChartAxis, setting major-tick-factory is the recommended technique for controlling the appearance of major ticks.


generate-major-ticks (method)
protected abstract {ChartAxis.generate-major-ticks}:void

Generate all Shapes required to represent the major ticks along this axis.

Description

This is the method in which ChartAxis implementations actually do the work of figuring out how many ticks to generate, where to place them, and actually doing so. This method is intended to be called from ChartAxis.update-layout.

If you are implementing this method, you may find it useful to use ChartAxis.generate-major-tick to create a standard tick shape. Generated Shapes should be added to ChartAxis.major-tick-group.


generate-minor-tick (method)
public {ChartAxis.generate-minor-tick
    value:any,
    tick-index:int,
    position:Distance = {self.get-position value}
}:Shape

Generate a Shape representing a minor tick.

value: The data value representing this tick. This may be passed to ChartAxis.get-position and used as ChartTick.value
tick-index: The zero-based index of this tick. This can be useful for features such as changing the color of alternating ticks.
position: The position along the axis at which the tick is to be placed. By default, ChartAxis.get-position is called using value to get the correct position. You only need pass a value using position if you have already calculated it; this is an optimization only.

Returns

A Shape representing the tick.

Description

This method could be called by implementations of ChartAxis.generate-minor-ticks to create the required ticks.

It is implemented to call the value of minor-tick-factory, if any; otherwise, it creates a MinorTickShape. Regardless of its source, the resulting Shape is added to ChartAxis.minor-tick-group, and returned.

Notes

Unless you are subclassing ChartAxis, setting minor-tick-factory is the recommended technique for controlling the appearance of major ticks.

Minor ticks are not created by default; to create them, you must create your own subclass of ChartAxis or one of its implementations, and override ChartAxis.generate-minor-ticks.


generate-minor-ticks (method)
protected abstract {ChartAxis.generate-minor-ticks}:void

Generate all Shapes required to represent the minor ticks along this axis.

Description

This is the minor tick counterpart to ChartAxis.generate-major-ticks. None of the standard axis implementations generate any minor ticks, and so ChartAxis.generate-minor-ticks does nothing. This method is intended to be called from ChartAxis.update-layout.

If you are implementing this method, you may find it useful to use ChartAxis.generate-minor-tick to create a standard tick shape. Generated Shapes should be added to ChartAxis.minor-tick-group.


generate-tick-label (method)
public {ChartAxis.generate-tick-label
    tick:ChartTick,
    tick-rotation:Angle
}:#Shape

Generate a tick label for the given tick.

tick: The ChartTick for which the label is to be created.
tick-rotation: The Angle at which the tick should be placed. This is usually controlled by tick-label-rotation.

Returns

A Shape representing the label, or null if no tick label should be displayed for this value.

Description

You may wish to override this method if you are subclassing an existing ChartAxis class. See ChartAxis.get-tick-label for a more complete discussion of controlling the appearance of the tick labels.

The Shape created need not be positioned, as ChartLabelGroup will set its position directly as appropriate to the axis' position. (Rotation and scale will not be affected.) If you wish to specify an offset with respect to that position, you can apply the desired transformation to the label shape and then embed it within a ShapeGroup. The ShapeGroup will be the object that is positioned by ChartLabelGroup, and the child Shape you embedded will be brought along with it. See axis-label for an example that demonstrates a similar technique using scaling for an axis label.

You must take care that the object generated is positioned well with respect to its origin. The origin will be placed such that it is positioned at the tick, offset by axis-label-group-spacing in the direction the tick points. You will need to position the shape you generate carefully to ensure it is where you want it to be (rather than, for instance, overlapping the axis and ticks).

See tick-label-factory for a discussion of how to ensure this using options like halign or horigin on objects like TextShape.

Notes

This is usually implemented to simply display ChartTick.value in a TextShape. DataSeriesAxis overrides this method to use Domain.format to ensure an appropriate String representation is used.


get-axis-label (method)
public final {ChartAxis.get-axis-label}:#Shape

Create a Shape appropriate for use as the label for this axis.

Returns

A Shape, or null if no axis label should be displayed.

Description

This method converts the axis-label option into a Shape, as required. By default, axis-label is a procedure that calls ChartAxis.generate-axis-label.

This structure is in place so that ChartAxis implementations can override label generation in a way that makes sense for the axis without overriding a user-specified axis-label option.

If you want to override label generation and you are subclassing ChartAxis, then you should override ChartAxis.generate-axis-label. Otherwise, you should set axis-label.

Example

See axis-label for a demonstration of using that option to control the axis label.


get-data-type (method)
public abstract {ChartAxis.get-data-type
}:(type:AxisDataType, value:any)

Describes the way in which a ChartAxis is defined.

Returns

An AxisDataType describing the data or metric associated with this axis and a value describing that metric.

Description

This method is used by the LayeredChart system that matches axes with data. For instance, if this axis is directly associated with a ChartDataSeries, then it is appropriate to associate it with plots of that data series. So, this method would return AxisDataType.data-series, along with the data series used within the axis.

The table below explains the type of value expected to be returned for each possible AxisDataType.

AxisDataTypeType of valueDescription
AxisDataType.data-series{Array-of ChartDataSeries}This axis is directly associated with one or more ChartDataSeries, and those series are contained in the array returned. All data series must share the same Domain object. (This is the most commonly used type of axis by far.)
AxisDataType.record-field{Array-of RecordField}This axis is directly associated with one or more RecordFields. All fields must share the same Domain. Data will be matched to the axis if it uses the same field. The RecordFields used are returned in an array.
AxisDataType.field-name{Array-of String}In a manner very similar to AxisDataType.record-field, this axis is associated with one or more record fields by name. Data will be matched to this axis if it uses a field of the same name. The field names used are returned in an array.
AxisDataType.typeTypeThe axis defines itself only as measuring a certain Type. NumericAxis-of is an example of this axis type. Failing a better match, any data that uses the same type will be matched to this axis.
AxisDataType.record-indexnone (null)This axis simply puts one Record after another, with no regard to the data. This axis type is only useful for X axes. It will match any data, but is the lowest priority kind of match. DefaultChartAxis and DefaultBarChartAxis are examples of this kind of axis.


get-major-ticks-Iterator (method)
public {ChartAxis.get-major-ticks-Iterator}:{Iterator-of ChartTick}

Returns an Iterator-of useful for iterating through the ticks in this axis.

Returns

An Iterator-of ChartTick.

Description

This method is used internally for generating tick labels and grid lines. It could be useful in applications for similar tasks; for instance, an applet could present some user interface element that corresponded to each tick, such as an option to highlight values at that tick.

Notes

The returned iterator only returns generated ticks that also subclass ChartTick. This will only matter if you change the ticks generated by subclassing ChartAxis.generate-major-ticks or setting major-tick-factory. Otherwise, all ticks will always be ChartTicks.

If you do create your own tick objects, and they do not subclass from ChartTick, then they will be absent here. As a result, no tick label or grid line will be generated for that tick. See major-tick-factory for an example of ow to create your own ChartTick subclass.


get-minor-ticks-Iterator (method)
public {ChartAxis.get-minor-ticks-Iterator}:{Iterator-of ChartTick}

Returns an Iterator-of useful for iterating through the ticks in this axis.

Returns

An Iterator-of ChartTick.

Description

This method is identical to ChartAxis.get-major-ticks-Iterator, except that it pertains to minor ticks.

Notes

Minor ticks are not created by default; to create them, you must create your own subclass of ChartAxis or one of its implementations, and override ChartAxis.generate-minor-ticks.


get-position (method)
public {ChartAxis.get-position value:any}:Distance

Calculate the spatial position corresponding to a data value.

value: A value whose expected type varies depending on the axis type. Passing an incompatible type will result in an error.

Returns

A Distance, measured from the origin of the ChartAxis along its length. Note that this will return decreasing (and, thus, negative) values for vertical axes, as the axis extends up -- that is, in the negative Y direction.

Description

Usually, it is easier to use a ChartDataMapping obtained via ChartLayer.get-data-mapping for this purpose. However, if you wish to look up an arbitrary value, rather than a particular Record corresp, this method can be useful.

The expected Type of value varies based on the axis implementation. This can be broken down based on AxisDataType, as obtained by ChartAxis.get-data-type:

AxisDataTypeExpected type of value
AxisDataType.data-seriesThe Type of the data provided, i.e., ChartDataSeries.field.domain.type.
AxisDataType.record-field{Array-of RecordField}The Type of the field, i.e., RecordField.domain.type.
AxisDataType.field-name{Array-of String}Defined by the specific axis implementation.
AxisDataType.typeTypeThe same Type returned by ChartAxis.get-data-type.
AxisDataType.record-indexnone (null)An int representing a zero-based record index.


get-position-at-zero (method)
public abstract {ChartAxis.get-position-at-zero}:Distance

Get the spatial position along this axis corresponding with zero.

Description

This returns a value along this axis' length with the same behavior as ChartAxis.get-position; see that method for details.

Notes

The concept of zero may not make sense for all axes. In particular, GenericDataSeriesAxis and EnumeratedBarChartAxis are ordinal axes, not continuous value-based axes, and so the concept of zero does not apply. Such axes always return 0m.


get-relative-position (method)
public abstract {ChartAxis.get-relative-position value:any}:Fraction

Calculate the spatial position corresponding to a data value.

value: A value whose expected type varies depending on the axis type. See ChartAxis.get-position. Passing an incompatible type will result in an error.

Returns

A Fraction indicating the position of the data value along the axis, ranging from 0 at the origin of the axis to 1 at the end of the axis.

Description

This is essentially the same as ChartAxis.get-position without any notion of the direction or length of the axis. In fact, that method is implemented in terms of this one. See ChartAxis.get-position for more information.


get-tick-label (method)
public final {ChartAxis.get-tick-label
    tick:ChartTick,
    tick-rotation:Angle
}:#Shape

Create a Shape appropriate for use as the label for a tick.

tick: The ChartTick for which the label is to be created.
tick-rotation: The Angle at which the tick should be placed. This is usually controlled by tick-label-rotation.

Returns

A Shape representing the label, or null if no tick label should be displayed for this value.

Description

This method calls the procedure stored in the tick-label-factory option and converts the result into a Shape, as required. By default, tick-label-factory is a procedure that calls ChartAxis.generate-tick-label.

This structure is in place so that ChartAxis implementations can override label generation in a way that makes sense for the axis without overriding a user-specified tick-label-factory option.

If you want to override label generation and you are subclassing ChartAxis, then you should override ChartAxis.generate-tick-label. Otherwise, you should set tick-label-factory.

Example

See tick-label-factory for a demonstration of using that option to control the tick label.


get-tick-label-alignment (method)
public {ChartAxis.get-tick-label-alignment
    rotation:Angle
}:(halign:String, valign:String)

Retrieve the default alignment for tick labels.

rotation: The tick rotation angle, usually resulting from the value of tick-label-rotation.

Returns

Two Strings describing, respectively, horizontal and vertical alignments recommended for this axis' tick labels.

Description

This method returns alignment values suitable for objects like TextShape or Frame. These values are based on ChartAxis.position and rotation.

This method is primarily for internal use, although you may find it useful in implementing tick label factories. See tick-label-factory for details on how to do so.


get-value (method)
public {ChartAxis.get-value position:Distance}:any

Calculate the data value that corresponds with a position along this axis.

position: The position along this axis. This should be between 0m and ChartAxis.length (or -ChartAxis.length, if this axis is vertical).

Returns

A value of the appropriate type for this axis. See ChartAxis.get-position for a discussion of the appropriate Types of values for different axes.

Description

Usually, it is more convenient to use ChartInverseDataMapping via ChartLayer.get-inverse-data-mapping. However, you may find it useful to interact directly with the axis on occasion.

For most axes, the returned value will be the nearest value contained in the source data (or the nearest record index, in the case of record-index-based axes). However, NumericDataSeriesAxis-of and NumericAxis-of will return continuous values within their domain.


get-value-relative (method)
public abstract {ChartAxis.get-value-relative position:Fraction}:any

Calculate the data value that corresponds with a position along this axis.

position: The position along this axis as a fraction. This should be between 0 and 1, inclusive.

Returns

A value of the appropriate type for this axis. See ChartAxis.get-position for a discussion of the appropriate Types of values for different axes.

Description

This is essentially the same as ChartAxis.get-value without any notion of the direction or length of the axis. In fact, that method is implemented in terms of this one. See ChartAxis.get-value for more information.


note-min-max-computation-changed (method)
public {ChartAxis.note-min-max-computation-changed}:void

Notifies this ChartAxis of a change in some factor affecting the values returned by LayeredChart.compute-data-min-max.

Description

Typically, implementations that rely on LayeredChart.compute-data-min-max will want to recompute their minimum and maximum and ensure that their layout has been invalidated. DataSeriesAxis and all of its subclasses do this automatically. You should never need to call this method directly; it is called from LayeredChart.note-min-max-computation-changed.

Please note that this method will not be called when the data itself changes; for that, you should use Observer.observe on the ChartDataSeries.
Introduced in: version 6.0


regenerate-shapes (method)
public {ChartAxis.regenerate-shapes}:void

Create all Shape objects required to represent this axis.

Description

This method generates the required shapes by calling the following methods in order:

  1. ChartAxis.clear-shapes
  2. ChartAxis.generate-axis-line
  3. ChartAxis.generate-major-ticks
  4. ChartAxis.generate-minor-ticks
  5. ChartAxis.label-group.update-layout

Notes

This method is only ever expected to be called by ChartAxis.update-layout. However, it may be useful to override in a subclass if you wish to receive notification of when this occurs.


transform-from-chart (method)
public {ChartAxis.transform-from-chart point:Distance2d}:Distance2d

Transforms a point from the LayeredChart's coordinate system into that of this ChartAxis.

point: The Distance2d to transform.

Returns

point, in local coordinates.

Description

This is essentially a convenience method, shorthand for a series of calls to Transformation2d.inverse-transform-point on the transformation property of the following objects in turn:

  1. LayeredChart.axis-group
  2. the axis parent's parent, i.e. LayeredChart.h-axis-group
  3. the axis parent, i.e. LayeredChart.left-axis-parent
  4. ChartAxis

Notes

This method can be useful for converting a position from chart coordinates for the purpose of calling ChartAxis.get-value.


transform-to-chart (method)
public {ChartAxis.transform-to-chart point:Distance2d}:Distance2d

Transforms a point from this ChartAxis' local coordinate system to that of the containing LayeredChart.

point: The Distance2d to transform.

Returns

point, in LayeredChart coordinates.

Description

This is essentially a convenience method, shorthand for a series of calls to Transformation2d.transform-point on the transformation property of the following objects in turn:

  1. ChartAxis
  2. the axis parent, i.e. LayeredChart.left-axis-parent
  3. the axis parent's parent, i.e. LayeredChart.h-axis-group
  4. LayeredChart.axis-group

Notes

This method can be useful when you want to add or move objects at the chart level based on, for instance, the results of ChartAxis.get-position.


update-layout (method)
public {ChartAxis.update-layout length:Distance}:void

Perform all required layout operations for the axis.

length: The length of the axis. ChartAxis.length will be set to this value.

Description

ChartAxis.update-layout regenerates all generated Shapes associated with this axis. To do this, it calls ChartAxis.clear-shapes and ChartAxis.regenerate-shapes.

This method is called by LayeredChart.update-layout during the chart layout process. It should never be necessary for you to call it directly; however, it may be useful to override this method in subclasses to perform operations immediately before or after the axis performs layout.