Class Axis2D

  • All Implemented Interfaces:
    EventListener, IGProp<GProp<?>[]>, IPropCnr, IPropCnrBooleanSettings<AxisOption>, IPropCnrChoiceSettings<IAxisChoiceOption>, IPropCnrColorSettings<AxisColor>, IPropCnrFontSettings<AxisFont>, IPropCnrIntegerSettings<AxisInteger>, IPropCnrKStringSettings<AxisKString>, IPropCnrNumberSettings<AxisNumber>, IPropCnrStrokeSettings<AxisStroke>, IChartContainer, java.lang.Cloneable
    Direct Known Subclasses:
    EAxis2D

    public class Axis2D
    extends PropCnr
    implements IChartContainer, IPropCnrBooleanSettings<AxisOption>, IPropCnrIntegerSettings<AxisInteger>, IPropCnrNumberSettings<AxisNumber>, IPropCnrKStringSettings<AxisKString>, IPropCnrFontSettings<AxisFont>, IPropCnrColorSettings<AxisColor>, IPropCnrStrokeSettings<AxisStroke>, IPropCnrChoiceSettings<IAxisChoiceOption>
    A chart axis is normally added to charts. They are either created in the Designer or constructed at runtime and added to the chart. The Designer chart axis persists in XML and can be predefined and only modified at runtime with the required settings.

    The axis has several options for defining axes. The first option is vertical, which determines if the axis is vertical or horizontal, and defaults to false, which of course means the axis would be horizontal. Make sure that your alignment matches with values set for hAxis and vAxis, which should be "x" and "y", by default, on your plot or your chart will not render and the validation will produce an error.

    Next there are the fixUpper and fixLower settings, which align the ticks and have 4 available options: MAJOR, MINOR, MICRO, and NONE. These default to NONE, and when set will force the end bounds to align to the corresponding tick division. If NONE is chosen, the end bounds will be the highest and lowest values in the data set.

    Another related option is the "includeZero" option, which will make the lower bound be zero instead of the lowest value. If the lowest data value is negative the "includeZero" option has no effect.

    If you wish to have two axis in the same direction, the second one should be set to be secondary. A secondary axis for horizontal is placed above the chart, and for a vertical axis on the right side (unless Right-To-Left [RTL] is in effect).

    You can use this to have different min/max ranges for the different axis in the same direction for different data series that are using the axes in question. You will then change the perspective of the second data set to the secondary axis and you have full control to adjust the axis in almost every way possible.

    You can turn on and off the tick marks at the minor and micro level, and turn labels on and off for the major and minor levels. There's natural (floating point numbers), which forces all ticks to be on natural numbers, and fixed which will fix the precision on your labels. If you want you can define the step between the ticks.

    You can control the color of the axis, the color and length of your tick marks, and the font and color of your labels.

    Styled Axis

    You can also add a grid at your tick marks to your entire chart by adding a Grid plot. The grid plot allows you to turn the grid on and off for major and minor ticks in both directions, and you can assign axes names if you have multiple axes.

    Last but not least, you have the ability to assign custom labels to your axis. Make sure to allow sufficient space in your chart area in the panel for the text to display properly.

    Author:
    Christopher Mindus
    • Constructor Detail

      • Axis2D

        public Axis2D​(java.lang.String name)
        Constructs a new horizontal axis from a name.
        Parameters:
        name - The name of the series. The name MUST be a valid Atom name and cannot start with "$".
        Throws:
        java.lang.NullPointerException - If the name is null.
        java.lang.IllegalArgumentException - If the name is invalid.
      • Axis2D

        public Axis2D​(java.lang.String name,
                      boolean isVertical)
        Constructs a new horizontal axis from a name.
        Parameters:
        name - The name of the series. The name MUST be a valid Atom name.
        isVertical - The vertical flag.
        Throws:
        java.lang.NullPointerException - If the name is null.
        java.lang.IllegalArgumentException - If the name is invalid.
      • Axis2D

        public Axis2D()
        Constructs a new axis without a name.

        This constructor is used by the persistence framework and should not be used.

      • Axis2D

        public Axis2D​(Atom atom)
        Constructs a new axis from an Atom name.

        This constructor is used by the persistence framework and should not be used.

        Parameters:
        atom - The atom name.