public abstract class

Axis

extends Object
java.lang.Object
   ↳ com.shinobicontrols.charts.Axis<T extends java.lang.Comparable<T>, U>
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Responsible for managing the coordinate space of the chart. It is the link between the set of real data in a Series and the laying down of that series on a ShinobiChart in a desired manner. Each series on the chart is linked to an Axis and this axis is responsible for managing all of the series linked to it.

The axis range can be set to a desired range or left to calculate its own minimum and maximum. When auto-calculating the range, it will consider all data series associated with it.

The axis is also the home of the tick marks and their labels. These can be auto-calculated or set to specific values.

Do not attempt to create your own direct subclasses of Axis, but if you have a need for advanced customization you should start from NumberAxis, DateTimeAxis or CategoryAxis

See Also

Summary

Nested Classes
enum Axis.DoubleTapBehavior Describes the behavior of the axis when the chart receives a double tap gesture. 
enum Axis.MotionState States describing internally generated axis range changes. 
enum Axis.Orientation The orientation of the axis. 
enum Axis.Position The position of the axis on the chart. 
Public Methods
void addSkipRange(Range<T> skipRange)
Instructs this axis to exclude the given range from the chart.
void addSkipRanges(List<? extends Range<T>> skipRanges)
Instructs this axis to exclude the given ranges from the chart.
void allowPanningOutOfDefaultRange(boolean allowPanningOutOfDefaultRange)
Sets whether or not the user is permitted to pan outside of the user-set default range.
void allowPanningOutOfMaxRange(boolean allowPanningOutOfMaxRange)
Sets whether or not the user is permitted to pan outside of the max range for this axis, where the max range is the union of this axis' data range and its default range.
void enableAnimation(boolean animationEnabled)
Sets whether or not the axis animates when zooming programmatically, or via a double-tap gesture.
void enableBouncingAtLimits(boolean bounceAtLimits)
Sets whether or not the axis allows the range to temporarily go past the limit specified before bouncing back in.
void enableDoubleTap(boolean doubleTapEnabled)
This method enables or disables the double tap gesture recognition.
void enableGesturePanning(boolean enableGesturePanning)
Sets whether to allow swipe gestures to pan the chart for this axis.
void enableGestureZooming(boolean enableGestureZooming)
Sets whether to allow pinch gestures to zoom the chart for this axis.
void enableMomentumPanning(boolean enableMomentumPanning)
Sets whether panning with momentum is enabled for this axis.
void enableMomentumZooming(boolean enableMomentumZooming)
Sets whether zooming with momentum is enabled for this axis.
final ShinobiChart getChart()
The chart this axis is attached to.
final Range<T> getCurrentDisplayedRange()
Gets the current displayed range of the axis.
final U getCurrentMajorTickFrequency()
Gets the current major tick frequency.
final U getCurrentMinorTickFrequency()
Gets the current minor tick frequency.
final Range<T> getDataRange()
Gets the total data range across all series represented by this axis.
final Range<T> getDefaultRange()
Returns a copy of the user-set range that will be displayed when data is loaded into the chart, or when the zoom is reset.
Axis.DoubleTapBehavior getDoubleTapBehavior()
This method returns the value of the DoubleTapBehavior that is configured for this Axis.
String getExpectedLongestLabel()
Returns the string representing the expected longest tick label size.
final U getMajorTickFrequency()
Gets the user-supplied value of the major tick frequency, which overrides the internally set (default) value.
final U getMinorTickFrequency()
Gets the value of the minor tick frequency being used, which overrides the internally set (default) value.
Axis.MotionState getMotionState()
Gets the motion state of the axis
final Axis.Orientation getOrientation()
Gets the orientation of the axis.
float getPixelValueForUserValue(T userValue)
Calculates the pixel position (X or Y, depending on the axis orientation) corresponding to a data value, based on the axis's current range.
final Axis.Position getPosition()
Gets the position of the axis.
final U getRangePaddingHigh()
Gets, in data terms, the amount by which the upper limit of the axis range will be raised past the range of the data.
final U getRangePaddingLow()
Gets, in data terms, the amount by which the lower limit of the axis range will be lowered past the range of the data.
List<Range<T>> getSkipRanges()
Returns an unmodifiable list of all the skip ranges that have been added to this axis.
AxisStyle getStyle()
Gets the AxisStyle object that manages the style for this axis.
TickMark.ClippingMode getTickMarkClippingModeHigh()
Gets the options for clipping tick marks at the high end of the range for this axis.
TickMark.ClippingMode getTickMarkClippingModeLow()
Gets the options for clipping tick marks at the low end of the range for this axis.
final String getTitle()
Gets the text of the Title for this axis.
T getUserValueForPixelValue(float pixelValue)
Calculates data value corresponding to a current pixel position (X or Y, depending on the axis orientation), based on the axis's current range.
final Range<T> getVisibleRange()
Returns a range within which all the visible (non-hidden) series on this axis will be displayed.
final Float getWidth()
Gets the specified fixed width for the axis area that will not change, in pixels.
double getZoomLevel()
Returns the current zoom level, relative to this axis' default range.
boolean isAnimationEnabled()
Whether or not the axis animates when zooming programmatically, or via a double-tap gesture.
boolean isBouncingAtLimitsEnabled()
Whether or not the axis allows the range to temporarily go past the limit specified before bouncing back in.
final boolean isCurrentDisplayedRangePreservedOnUpdate()
Whether the current visible range is preserved when new data comes into the chart.
boolean isDoubleTapEnabled()
This method returns true if the double tap gesture recognition is enabled, and false otherwise.
boolean isGesturePanningEnabled()
Whether swipe gestures pan the chart for this axis.
boolean isGestureZoomingEnabled()
Whether pinch gestures zoom the chart for this axis.
boolean isMomentumPanningEnabled()
Whether panning with momentum is enabled for this axis.
boolean isMomentumZoomingEnabled()
Whether zooming with momentum is enabled for this axis.
boolean isPanningOutOfDefaultRangeAllowed()
Whether or not the user is permitted to pan outside of the user-set default range.
boolean isPanningOutOfMaxRangeAllowed()
Whether or not the user is permitted to pan outside of the max range for this axis, where the max range is the union of this axis' data range and its default range.
void removeAllSkipRanges()
Removes all skip ranges currently added to this axis.
void removeSkipRange(Range<T> skipRange)
Removes the given range from the list of excluded ranges for this axis.
void removeSkipRanges(List<? extends Range<T>> skipRanges)
Removes the given ranges from the list of excluded ranges for this axis.
boolean requestCurrentDisplayedRange(T minimum, T maximum)
Attempts to set the current visible range, axisRange, to a range with the given minimum and maximum values in line with any restrictions on setting the range, such as allowPanningOutOfMaxRange(boolean) This overload takes account the axis's isAnimationEnabled() and isBouncingAtLimitsEnabled() state

The permissible types of minimum and maximum will vary depending on the type of axis in use.

boolean requestCurrentDisplayedRange(T minimum, T maximum, boolean animation, boolean bounceAtLimits)
Attempts to set the current visible range, axisRange, to a range with the given minimum and maximum values in line with any restrictions on setting the range, such as allowPanningOutOfMaxRange(boolean) .
final void setCurrentDisplayedRangePreservedOnUpdate(boolean preserved)
Sets whether the current visible range is preserved when new data comes into the chart.
final void setDefaultRange(Range<T> defaultRange)
Sets the range that will be displayed when data is loaded into the chart, or when the zoom is reset.
void setDoubleTapBehavior(Axis.DoubleTapBehavior behavior)
Call this method to configure the behavior for double taps.
void setExpectedLongestLabel(String longestLabel)
Sets the string representing the expected longest tick label size.
final void setMajorTickFrequency(U majorTickFrequency)
Sets the major tick frequency.
void setMajorTickMarkValues(List<T> values)
Sets a list of values to be used as the major tick mark values for this axis.
final void setMinorTickFrequency(U minorTickFrequency)
Sets the minor tick frequency.
final void setPosition(Axis.Position axisPosition)
Sets the position of the axis.
final void setRangePaddingHigh(U rangePaddingHigh)
Sets, in data terms, the amount by which the upper limit of the axis range will be raised past the range of the data.
final void setRangePaddingLow(U rangePaddingLow)
Sets, in data terms, the amount by which the lower limit of the axis range will be lowered past the range of the data.
final void setStyle(AxisStyle style)
Sets the AxisStyle object that manages the style for this axis.
void setTickMarkClippingModeHigh(TickMark.ClippingMode tickLabelClippingModeHigh)
Sets the options for clipping tick marks at the high end of the range for this axis.
void setTickMarkClippingModeLow(TickMark.ClippingMode tickLabelClippingModeLow)
Sets the options for clipping tick marks at the low end of the range for this axis.
final void setTitle(String title)
Sets the text of the Title for this axis.
final void setWidth(Float width)
Sets a fixed width for the axis area that will not change, in pixels.
void specifyBarColumnSpacing(U spacing)
Optionally specifies your expected data spacing for bar, column, candlestick and OHLC series within the chart.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void addSkipRange (Range<T> skipRange)

Instructs this axis to exclude the given range from the chart. The values inside the range are said to be 'skipped' - this is most commonly used for omitting periods of time on a DateTimeAxis such as weekends or bank holidays. The axis will be updated to reflect the changes. Any data values that fall within a skipped range will not be displayed.

It is possible to add multiple skip ranges to an axis but it should be borne in mind that every time a skip range is added to an axis, a number of internal calculations must be made. Additionally, the chart it belongs to will be instructed to reload its data. As such there are a number of ways to improve the efficiency of such an operation:

  • Add all of the skip ranges in one go by using the addSkipRanges(List) method.
  • Ensure the axis is not connected to a chart when adding the skip ranges (temporarily removing it if necessary).
Doing the above minimizes the number of internal calculations that need to be made and prevents repeated calls to the chart to reload its data.

Attempting to add ranges of zero or negative span will be ignored.

Parameters
skipRange the range to be excluded from the chart on this axis

public void addSkipRanges (List<? extends Range<T>> skipRanges)

Instructs this axis to exclude the given ranges from the chart. The values inside the ranges are said to be 'skipped' - this is most commonly used for omitting periods of time on a DateTimeAxis such as weekends or bank holidays. The axis will be updated to reflect the changes. Any data values that fall within a skipped range will not be displayed.

Adding a list of skip ranges altogether, instead of doing so one at a time, can be more efficient and improve data loading time. Similarly, it is more efficient to add the skip ranges while the axis is not connected to a chart as it avoids repeated data reload requests. Consider temporarily removing the axis from the chart while you add the skip ranges, or adding the skip ranges before the axis is given to the chart.

Attempting to add ranges of zero or negative span will be ignored.

Parameters
skipRanges the ranges to be excluded from the chart on this axis

public void allowPanningOutOfDefaultRange (boolean allowPanningOutOfDefaultRange)

Sets whether or not the user is permitted to pan outside of the user-set default range. If the default range is not set, the range of this axis' data is used instead and allowPanningOutOfMaxRange(boolean) should be used instead.

Parameters
allowPanningOutOfDefaultRange set to true to allow the user to pan outside of this axis' default range

public void allowPanningOutOfMaxRange (boolean allowPanningOutOfMaxRange)

Sets whether or not the user is permitted to pan outside of the max range for this axis, where the max range is the union of this axis' data range and its default range. Even if this is set to true panning will still be restricted to this axis' default range if isPanningOutOfDefaultRangeAllowed() is false.

Parameters
allowPanningOutOfMaxRange set to true to allow the user to pan outside the union of the data range and the default range for this axis

public void enableAnimation (boolean animationEnabled)

Sets whether or not the axis animates when zooming programmatically, or via a double-tap gesture. If this is enabled, the axis will zoom smoothly from starting to target zoom levels.

Parameters
animationEnabled whether or not the axis should animate when zooming

public void enableBouncingAtLimits (boolean bounceAtLimits)

Sets whether or not the axis allows the range to temporarily go past the limit specified before bouncing back in. If this is enabled, the range will bounce back into the given limit. If there is no range limit, this option does nothing.

Parameters
bounceAtLimits whether to allow the axis range to temporarily go past the specified limit before bouncing back in

public void enableDoubleTap (boolean doubleTapEnabled)

This method enables or disables the double tap gesture recognition.

Parameters
doubleTapEnabled Enables or disables the double tap gesture recognition.

public void enableGesturePanning (boolean enableGesturePanning)

Sets whether to allow swipe gestures to pan the chart for this axis.

Enabling panning gestures in both axes will prevent any parent views from using those gestures when used on the chart. If enabled only on one axis then it's possible that the parent can use those gestures even when done within a chart.

Parameters
enableGesturePanning set to true to enable swipe gestures to pan the chart for this axis

public void enableGestureZooming (boolean enableGestureZooming)

Sets whether to allow pinch gestures to zoom the chart for this axis.

Enabling zooming gestures in both axes will prevent any parent views from using those gestures when used on the chart. If enabled only on one axis then it's possible that the parent can use those gestures even when done within a chart.

Parameters
enableGestureZooming set to true to enable pinch gestures to zoom the chart for this axis

public void enableMomentumPanning (boolean enableMomentumPanning)

Sets whether panning with momentum is enabled for this axis. When panning with momentum is enabled, fast pan gestures will cause the chart to continue to pan during a brief 'slowing down' period rather than stopping immediately.

Parameters
enableMomentumPanning whether to enable panning with momentum

public void enableMomentumZooming (boolean enableMomentumZooming)

Sets whether zooming with momentum is enabled for this axis. When zooming with momentum is enabled, fast pinch gestures will cause the chart to continue to zoom during a brief 'slowing down' period rather than stopping immediately.

Parameters
enableMomentumZooming whether to enabled zooming with momentum

public final ShinobiChart getChart ()

The chart this axis is attached to.

Returns
  • The chart this axis is attached to.

public final Range<T> getCurrentDisplayedRange ()

Gets the current displayed range of the axis. This property is the actual range currently displayed on the visible area of the chart- which may not be the range that was explicitly set. The axis may make small adjustments to the range to make sure that whole bars are displayed etc. This is a read-only property – explicit requests to change the axis range should be made through the method requestCurrentDisplayedRange(T, T).

Returns
  • The current displayed range of the axis

public final U getCurrentMajorTickFrequency ()

Gets the current major tick frequency. This is the value that is actually being used by the chart, either user-supplied or internally generated

Returns
  • the current major tick frequency

public final U getCurrentMinorTickFrequency ()

Gets the current minor tick frequency. This is the value that is actually being used by the chart, either user-supplied or internally generated

Returns
  • the current minor tick frequency

public final Range<T> getDataRange ()

Gets the total data range across all series represented by this axis. These are absolute minimum and absolute maximum values from the data series represented by this axis. This range does not necessarily represent exactly the range of what is drawn on the axis, depending on how the data is visualised - for this see getVisibleRange.

Returns
  • The total data range across all series represented by this axis

public final Range<T> getDefaultRange ()

Returns a copy of the user-set range that will be displayed when data is loaded into the chart, or when the zoom is reset. If no defaultRange has been set this method will return null.

Directly modifying the returned Range object will have no effect on the chart's default range. Instead, use setDefaultRange(Range).

Where no defaultRange has been set, the displayed range will be the dataRange plus any range padding values specified. If any series on this axis have a custom baseline that is beyond the dataRange plus padding limits, the displayed range will be extended to include this.

Returns
  • A copy of the user-set range that is displayed after the chart initially loads and when the zoom is reset, null if not set

public Axis.DoubleTapBehavior getDoubleTapBehavior ()

This method returns the value of the DoubleTapBehavior that is configured for this Axis. It will either be the default Axis.DoubleTapBehavior.ZOOM_IN or Axis.DoubleTapBehavior.RESET_TO_DEFAULT_RANGE.

Returns
  • The DoubleTapBehavior for this Axis.

public String getExpectedLongestLabel ()

Returns the string representing the expected longest tick label size. This is your user-supplied value, which overrides the internal dynamic calculation of maximum label length.

Returns
  • the string representing the expected longest tick label

public final U getMajorTickFrequency ()

Gets the user-supplied value of the major tick frequency, which overrides the internally set (default) value.

Returns
  • The desired major tick frequency

public final U getMinorTickFrequency ()

Gets the value of the minor tick frequency being used, which overrides the internally set (default) value.

Returns
  • The desired major tick frequency

public Axis.MotionState getMotionState ()

Gets the motion state of the axis

Returns
  • the motion state of this axis

public final Axis.Orientation getOrientation ()

Gets the orientation of the axis. Axis objects are universal and may be used as an X-axis or as a Y-axis. This property is determined when the axis is assigned to the chart.

Returns
  • The orientation of the axis.
See Also

public float getPixelValueForUserValue (T userValue)

Calculates the pixel position (X or Y, depending on the axis orientation) corresponding to a data value, based on the axis's current range. The pixel value is relative to the whole chart.

This method will only return meaningful values after the chart has been laid out and is intended to be used in response to axis range changes and internal layout events (see ShinobiChart.OnAxisRangeChangeListener and ShinobiChart.OnInternalLayoutListener. As such, calling this in your android.app.Activity's onCreate() method will produce unexpected results.

Parameters
userValue The user data value
Returns
  • The pixel position (X or Y, depending on the axis orientation)

public final Axis.Position getPosition ()

Gets the position of the axis. The position defines whether the axis will be positioned at the normal or reverse location. Normal positions are bottom for an X-axis and left for a Y-axis.

Returns
  • The position of the axis

public final U getRangePaddingHigh ()

Gets, in data terms, the amount by which the upper limit of the axis range will be raised past the range of the data. By default this is set to null. A null rangePaddingHigh value equates to no high axis range padding.

Returns
  • The amount by which the upper limit of the axis range is raised past the range of the data

public final U getRangePaddingLow ()

Gets, in data terms, the amount by which the lower limit of the axis range will be lowered past the range of the data. By default this is set to null. A null rangePaddingLow value equates to no low axis range padding.

Returns
  • The amount by which the lower limit of the axis range is lowered past the range of the data

public List<Range<T>> getSkipRanges ()

Returns an unmodifiable list of all the skip ranges that have been added to this axis. By default this will be an empty list. Any invalid skip ranges that are attempted to be added to this axis will be ignored and not included in this list.

Returns
  • an unmodifiable list of all skip ranges currently on this axis

public AxisStyle getStyle ()

Gets the AxisStyle object that manages the style for this axis. Setting these values will override any values set by the theme. Any changes to properties on the style are not reflected visually until redrawChart() is called.

Returns
  • The axis style object that managed the style for this axis

public TickMark.ClippingMode getTickMarkClippingModeHigh ()

Gets the options for clipping tick marks at the high end of the range for this axis.

Returns
  • The high clipping mode for this axis.

public TickMark.ClippingMode getTickMarkClippingModeLow ()

Gets the options for clipping tick marks at the low end of the range for this axis.

Returns
  • The low clipping mode for this axis.

public final String getTitle ()

Gets the text of the Title for this axis.

Returns
  • The text of the title for this axis
See Also

public T getUserValueForPixelValue (float pixelValue)

Calculates data value corresponding to a current pixel position (X or Y, depending on the axis orientation), based on the axis's current range. The pixel value is relative to the whole chart.

This method will only return meaningful values after the chart has been laid out and is intended to be used in response to axis range changes and internal layout events (see ShinobiChart.OnAxisRangeChangeListener and ShinobiChart.OnInternalLayoutListener. As such, calling this in your android.app.Activity's onCreate() method will produce unexpected results.

Parameters
pixelValue The pixel position (X or Y, depending on the axis orientation)
Returns
  • The user data value

public final Range<T> getVisibleRange ()

Returns a range within which all the visible (non-hidden) series on this axis will be displayed. Setting the default range to this range should frame your data nicely. Note that this will take baselines, bar/column widths etc. into consideration.

Returns
  • A range that will display all visible series on this axis

public final Float getWidth ()

Gets the specified fixed width for the axis area that will not change, in pixels. This is useful to fix the axis in position to align multiple charts. However, it may restrict the options for labeling the chart. Note if you call this method without first setting the width value (by using #setWidth(Float)) this method will return null.

Returns
  • The specified fixed width for the axis area that will not change
See Also

public double getZoomLevel ()

Returns the current zoom level, relative to this axis' default range.

Returns
  • the current zoom level for this axis

public boolean isAnimationEnabled ()

Whether or not the axis animates when zooming programmatically, or via a double-tap gesture. If this is enabled, the axis will zoom smoothly from starting to target zoom levels.

Returns
  • whether or not the axis animates when zooming

public boolean isBouncingAtLimitsEnabled ()

Whether or not the axis allows the range to temporarily go past the limit specified before bouncing back in. If this is enabled, the range will bounce back into the given limit. If there is no range limit, this option does nothing.

Returns
  • whether the axis range can temporarily go past the specified limit before bouncing back in

public final boolean isCurrentDisplayedRangePreservedOnUpdate ()

Whether the current visible range is preserved when new data comes into the chart. If this is false (the default) the range will reset to the data range, or the default range if you have one. If this is true, the current visible range will not change when new data is added.

Returns
  • Whether the current visible range is preserved when new data comes into the chart.

public boolean isDoubleTapEnabled ()

This method returns true if the double tap gesture recognition is enabled, and false otherwise. The default value is true.

Returns
  • true if the double tap gesture recognition is enabled, false otherwise

public boolean isGesturePanningEnabled ()

Whether swipe gestures pan the chart for this axis.

Returns
  • true if swipe gestures pan the chart for this axis, false if not

public boolean isGestureZoomingEnabled ()

Whether pinch gestures zoom the chart for this axis.

Returns
  • true if pinch gestures zoom the chart for this axis, false if not

public boolean isMomentumPanningEnabled ()

Whether panning with momentum is enabled for this axis. When panning with momentum is enabled, fast pan gestures will cause the chart to continue to pan during a brief 'slowing down' period rather than stopping immediately.

Returns
  • whether panning with momentum is enabled

public boolean isMomentumZoomingEnabled ()

Whether zooming with momentum is enabled for this axis. When zooming with momentum is enabled, fast pinch gestures will cause the chart to continue to zoom during a brief 'slowing down' period rather than stopping immediately.

Returns
  • whether zooming with momentum is enabled

public boolean isPanningOutOfDefaultRangeAllowed ()

Whether or not the user is permitted to pan outside of the user-set default range. With a user-set default range this can be used to either limit panning and zooming to a subset of the data or to allow panning or zooming outside of the data range while still setting limits. If the default range is not set, the range of this axis' data is used instead.

Returns
  • whether or not the user is permitted to pan outside the user-set default range

public boolean isPanningOutOfMaxRangeAllowed ()

Whether or not the user is permitted to pan outside of the max range for this axis, where the max range is the union of this axis' data range and its default range. If this is true but isPanningOutOfDefaultRangeAllowed() is false, panning will still be restricted to the default range

Returns
  • whether or not the user is permitted to pan outside of the union of the data range and the default range

public void removeAllSkipRanges ()

Removes all skip ranges currently added to this axis. The axis will be updated to reflect the changes.

public void removeSkipRange (Range<T> skipRange)

Removes the given range from the list of excluded ranges for this axis. The axis will be updated to reflect the changes.

Every time a skip range is removed from an axis, a number of internal calculations must be made. Additionally, the chart it belongs to will be instructed to reload its data. As such there are a number of ways to improve the efficiency of removing a large number of skip ranges:

  • If all of the skip ranges are to be removed use the removeAllSkipRanges() method.
  • To remove a subset of the skip ranges currently on an axis use the removeSkipRanges(List) method.
  • Ensure the axis is not connected to a chart when removing the skip ranges (temporarily removing it if necessary).
Doing the above minimizes the number of internal calculations that need to be made and prevents repeated calls to the chart to reload its data.

Parameters
skipRange the range to no longer be excluded from the chart on this axis

public void removeSkipRanges (List<? extends Range<T>> skipRanges)

Removes the given ranges from the list of excluded ranges for this axis. The axis will be updated to reflect the changes.

Removing a list of skip ranges altogether, instead of doing so one at a time, can be more efficient. Similarly, it is more efficient to remove the skip ranges while the axis is not connected to a chart as it avoids repeated data reload requests. Consider temporarily removing the axis from the chart while you remove the skip ranges.

Parameters
skipRanges the ranges to no longer be excluded from the chart on this axis

public boolean requestCurrentDisplayedRange (T minimum, T maximum)

Attempts to set the current visible range, axisRange, to a range with the given minimum and maximum values in line with any restrictions on setting the range, such as allowPanningOutOfMaxRange(boolean) This overload takes account the axis's isAnimationEnabled() and isBouncingAtLimitsEnabled() state

The permissible types of minimum and maximum will vary depending on the type of axis in use. The range of a NumberAxis should be set using two objects of type java.lang.Number (or one of its sub-classes) for minimum and maximum, while that of a DateTimeAxis can be configured using a minimum and maximum of type java.util.Date (or one of its sub-classes). In the case of CategoryAxis, the first value has a nominal value of ‘0’ and the nth value, ‘n-1’. For example:

 // Range from 20 to 140 on a NumberAxis.
 myNumberAxis.requestCurrentDisplayedRange(20.0, 140.0);
 
 // Range from June 2013 to January 2014 on a DateTimeAxis.
 myDateTimeAxis.requestCurrentDisplayedRange(
         new GregorianCalendar(2013, Calendar.JUNE, 01).getTime(),
         new GregorianCalendar(2014, Calendar.JANUARY, 01).getTime());
 
 // Range between the third and fifth elements on a CategoryAxis (zero indexed).
 myCategoryAxis.requestCurrentDisplayedRange(2, 6);
 

Parameters
minimum the minimum value to be displayed, in data terms
maximum the maximum value to be displayed, in data terms
Returns
  • Whether or not the operation was successful. True if the axis range has been set to (or is currently animating towards) the values you requested. False if the values have been limited by default or data ranges.

public boolean requestCurrentDisplayedRange (T minimum, T maximum, boolean animation, boolean bounceAtLimits)

Attempts to set the current visible range, axisRange, to a range with the given minimum and maximum values in line with any restrictions on setting the range, such as allowPanningOutOfMaxRange(boolean) . This overload allows you to explicitly set whether to animate the transition to the new range or not, and it ignores the axis's isAnimationEnabled() and isBouncingAtLimitsEnabled() state.

Parameters
minimum The minimum value to be displayed, in data terms
maximum The maximum value to be displayed, in data terms
animation Whether or not to animate the range change
bounceAtLimits Whether or not to allow the range change animation to temporarily go beyond the limits set
Returns
  • Whether or not the operation was successful. True if the axis range has been set to (or is currently animating towards) the values you requested. False if the values have been limited by default or data ranges.

public final void setCurrentDisplayedRangePreservedOnUpdate (boolean preserved)

Sets whether the current visible range is preserved when new data comes into the chart. If you set this false the range will reset to the data range, or the default range if you have one, when data is added. If you set this true, the current visible range will not change when new data is added.

Parameters
preserved Whether the current visible range is preserved when new data comes into the chart.

public final void setDefaultRange (Range<T> defaultRange)

Sets the range that will be displayed when data is loaded into the chart, or when the zoom is reset.

Note that setting this property after data is loaded into the chart may have no immediate effect - it's the default value, not the current value. If you want an immediate effect use requestCurrentDisplayedRange(T, T) . If, however, setting the default range means the current displayed range for this axis becomes invalid (due to any restrictions imposed) it will update accordingly.

Attempting to set a default range which has the same minimum value as its maximum value will result in an java.lang.IllegalArgumentException being thrown.

Where no defaultRange has been set, the displayed range will be the dataRange plus any range padding values specified. If any series on this axis have a custom baseline that is beyond the dataRange plus padding limits, the displayed range will be extended to include this.

Parameters
defaultRange The range to display after the chart initially loads and when the zoom is reset

public void setDoubleTapBehavior (Axis.DoubleTapBehavior behavior)

Call this method to configure the behavior for double taps. Either you can zoom in to 50% of the current value, using the default Axis.DoubleTapBehavior.ZOOM_IN, or you can reset the pan and zoom range to the defaults for this axis using Axis.DoubleTapBehavior.RESET_TO_DEFAULT_RANGE.

Parameters
behavior The setting for the DoubleTapBehavior for this axis.

public void setExpectedLongestLabel (String longestLabel)

Sets the string representing the expected longest tick label size. This will override the internal dynamic calculation of maximum label length.

Parameters
longestLabel the string to set as the expected longest tick label

public final void setMajorTickFrequency (U majorTickFrequency)

Sets the major tick frequency. This value will override the internally set (default) value. Values of 0 or less will be ignored. Note that it is the **major** tick frequency that determines whether or not your values are used. If you set the major tick frequency, the axis will use your major and minor values. If you do not set the major tick frequency, the internal values will be used, even if you have set a minor tick frequency. Minor tick frequencies may be null if you do not display minor tick marks. Note also that tick mark labels will be dropped (they will not be visible) if you set the frequency so that they would otherwise overlap.

Parameters
majorTickFrequency The desired major tick frequency

public void setMajorTickMarkValues (List<T> values)

Sets a list of values to be used as the major tick mark values for this axis. Calling this method with a non-null list will restrict the displayed tick marks to only those with the values in the list; no other values will be displayed. Subsequently calling this method with null will cause the tick marks to be automatically calculated as per usual. If called after the chart has already been rendered you must call redrawChart() for the new values to take effect.

The values can be specified in any order but will be displayed in ascending order along the axis. Any duplicates in the list will be removed. If the list contains null for any of its elements an java.lang.IllegalArgumentException will be thrown.

Custom major tick mark values cannot be set on a CategoryAxis. Any attempt to do so will be ignored. Also note that enabling grid stripes with custom tick mark values is not supported and may lead to some undesired visual effects.

Parameters
values the list of tick mark values to show on this axis

public final void setMinorTickFrequency (U minorTickFrequency)

Sets the minor tick frequency. This value will override the internally set (default) value. Values of 0 or less will be ignored. Note that it is the **major** tick frequency that determines whether or not your values are used. If you set the major tick frequency, the axis will use your major and minor values. If you do not set the major tick frequency, the internal values will be used, even if you have set a minor tick frequency. Minor tick frequencies may be null if you do not display minor tick marks.

Parameters
minorTickFrequency the desired minor tick frequency

public final void setPosition (Axis.Position axisPosition)

Sets the position of the axis. The position defines whether the axis will be positioned at the normal or reverse location. Normal positions are bottom for an X-axis and left for a Y-axis.

Parameters
axisPosition The position for the axis

public final void setRangePaddingHigh (U rangePaddingHigh)

Sets, in data terms, the amount by which the upper limit of the axis range will be raised past the range of the data.

Parameters
rangePaddingHigh The amount by which to raise the upper limit of the axis range past the range of the data. Passing in a null rangePaddingHigh value effectively resets the high axis range padding.

public final void setRangePaddingLow (U rangePaddingLow)

Sets, in data terms, the amount by which the lower limit of the axis range will be lowered past the range of the data.

Parameters
rangePaddingLow The amount by which to lower the limit of the axis range past the range of the data. Passing in a null rangePaddingLow value effectively resets the lower axis range padding.

public final void setStyle (AxisStyle style)

Sets the AxisStyle object that manages the style for this axis. Values in style will override any values set by the theme. The new style is not reflected visually until redrawChart() is called.

Parameters
style The axis style object to manage the style for this axis
See Also

public void setTickMarkClippingModeHigh (TickMark.ClippingMode tickLabelClippingModeHigh)

Sets the options for clipping tick marks at the high end of the range for this axis.

Parameters
tickLabelClippingModeHigh The high clipping mode for this axis.

public void setTickMarkClippingModeLow (TickMark.ClippingMode tickLabelClippingModeLow)

Sets the options for clipping tick marks at the low end of the range for this axis.

Parameters
tickLabelClippingModeLow The low clipping mode for this axis.

public final void setTitle (String title)

Sets the text of the Title for this axis.

Parameters
title The text of the title for this axis
See Also

public final void setWidth (Float width)

Sets a fixed width for the axis area that will not change, in pixels. This is useful to fix the axis in position to align multiple charts. However, it may restrict the options for labeling the chart. If you provide a null value the axis will adopt its default measuring strategy. In this case it will be dynamically measured. If you provide a negative or zero value, the axis will be assigned a zero width which will result in it not being visible on the chart. You must call redrawChart() for any changes to become visible.

Parameters
width The fixed width for the axis area that will not change
See Also

public void specifyBarColumnSpacing (U spacing)

Optionally specifies your expected data spacing for bar, column, candlestick and OHLC series within the chart. Important note. This is an advanced optimization setting which need only be called if you have large volumes of evenly spaced data using these series. The normal internal behaviour of the axis is to determine the visual size of the data points by calculating how much space is available. To do this it must consider each data point and the spacing between them, which is computationally expensive. This method allows you to bypass that process by specifying a fixed spacing based on your knowledge of the data you are supplying. E.g. if you know that your data consists of daily observations, you might specify a spacing of 1 day, thus saving the axis from having to consider each data point in order to come to the same conclusion. Specifying null returns the axis to its automatic behaviour.

Parameters
spacing The amount of space to use for a bar height or column, candlestick or OHLC width, expressed in user data (frequency).