Search Results for

    Show / Hide Table of Contents

    Axis APIs

    There are several axis types in SciChart Android. Although they all differ in types of data values that can be rendered, the most fundamental difference is in their behavior. By that, the axes can be divided into two groups, Category and Value axis types. Please read the Value Axis vs. Category Axis article elaborating on what the difference is.

    A list of the axis types are found below:

    Axis Type Value or Category Axis
    NumericAxis Value Axis
    LogarithmicNumericAxis Value Axis
    DateAxis Value Axis
    CategoryDateAxis Category Axis

    All the axis types in SciChart conforms to the IAxis protocol.

    NumericAxis

    The NumericAxis is a Value-Axis and is suitable for X and Y Axis when the data type on that axis is numeric (e.g. double, int, long, float, short). It is not suitable for non-numeric data types.

    To create and configure a NumericAxis, use the following code:

    • Java
    • Java with Builders API
    • Kotlin
    final NumericAxis axis = new NumericAxis(getContext());
    axis.setAxisAlignment(AxisAlignment.Right);
    axis.setAutoRange(AutoRange.Once);
    axis.setGrowBy(new DoubleRange(0.1, 0.1));
    axis.setVisibleRange(new DoubleRange(-45.0, 300.0));
    
    final NumericAxis axis = sciChartBuilder.newNumericAxis()
            .withAxisAlignment(AxisAlignment.Right)
            .withAutoRangeMode(AutoRange.Once)
            .withGrowBy(0.1, 0.1)
            .withVisibleRange(-45.0, 300.0)
            .build();
    
    val axis = NumericAxis(context)
    axis.axisAlignment = AxisAlignment.Right
    axis.autoRange = AutoRange.Once
    axis.growBy = DoubleRange(0.1, 0.1)
    axis.visibleRange = DoubleRange(-45.0, 300.0)
    

    LogarithmicNumericAxis

    The LogarithmicNumericAxis is a Value axis which uses non-linear (logarithmic) scale. It is suitable for X and Y Axis when the data is numeric (e.g. double, int, long, float, short). It is not suitable for non-numeric data types.

    Note

    The LogarithmicNumericAxis cannot render data values less than or equal to zero. Please ensure you append valid data to your DataSeries.

    To create and configure a LogarithmicNumericAxis, use the following code:

    • Java
    • Java with Builders API
    • Kotlin
    final LogarithmicNumericAxis axis = new LogarithmicNumericAxis(getContext());
    axis.setAxisAlignment(AxisAlignment.Right);
    axis.setAutoRange(AutoRange.Once);
    axis.setGrowBy(new DoubleRange(0.1, 0.1));
    
    // Specifies how labels appear on the axis
    axis.setScientificNotation(ScientificNotation.LogarithmicBase);
    axis.setTextFormatting("#.#E+0");
    
    // Specifies the logarithm base for the logarithmic scale of the axis
    axis.setLogarithmicBase(10.0);
    axis.setVisibleRange(new DoubleRange(0.1, 1000.0));
    
    final LogarithmicNumericAxis axis = sciChartBuilder.newLogarithmicNumericAxis()
            .withAxisAlignment(AxisAlignment.Right)
            .withAutoRangeMode(AutoRange.Once)
            .withGrowBy(0.1, 0.1)
            // Specifies how labels appear on the axis
            .withScientificNotation(ScientificNotation.LogarithmicBase)
            .withTextFormatting("#.#E+0")
            // Specifies the logarithm base for the logarithmic scale of the axis
            .withLogarithmicBase(10.0)
            .withVisibleRange(0.1, 1000.0)
            .build();
    
    val axis = LogarithmicNumericAxis(context)
    axis.axisAlignment = AxisAlignment.Right
    axis.autoRange = AutoRange.Once
    axis.growBy = DoubleRange(0.1, 0.1)
    
    // Specifies how labels appear on the axis
    axis.scientificNotation = ScientificNotation.LogarithmicBase
    axis.textFormatting = "#.#E+0"
    
    // Specifies the logarithm base for the logarithmic scale of the axis
    axis.logarithmicBase = 10.0
    axis.visibleRange = DoubleRange(0.1, 1000.0)
    

    DateAxis

    The DateAxis is a Value axis, which is suitable for X and Y Axis and is designed to work with dates only.

    Note

    The DateAxis is not suitable for numeric data types.

    To create and configure a DateAxis, use the following code:

    • Java
    • Java with Builders API
    • Kotlin
    final DateAxis axis = new DateAxis(getContext());
    axis.setAxisAlignment(AxisAlignment.Bottom);
    axis.setAutoRange(AutoRange.Once);
    axis.setGrowBy(new DoubleRange(0.1, 0.1));
    axis.setVisibleRange(new DateRange(dateMin, dateMax));
    
    final DateAxis axis = sciChartBuilder.newDateAxis()
            .withAxisAlignment(AxisAlignment.Bottom)
            .withAutoRangeMode(AutoRange.Once)
            .withGrowBy(0.1, 0.1)
            .withVisibleRange(dateMin, dateMax)
            .build();
    
    val axis = DateAxis(context)
    axis.axisAlignment = AxisAlignment.Bottom
    axis.autoRange = AutoRange.Once
    axis.growBy = DoubleRange(0.1, 0.1)
    axis.visibleRange = DateRange(dateMin, dateMax)
    

    CategoryDateAxis

    The CategoryDateAxis is a Category axis and is suitable for the XAxis only. It is designed to handle a special case when data is discontinuous or contains breaks at regular intervals. Unlike the other axis types, it works with with data indices, not actual data values.

    Note

    The CategoryDateAxis is not suitable for YAxis or numeric data types.

    To create and configure a CategoryDateAxis, use the following code:

    • Java
    • Java with Builders API
    • Kotlin
    final CategoryDateAxis axis = new CategoryDateAxis(getContext());
    axis.setAxisAlignment(AxisAlignment.Top);
    axis.setAutoRange(AutoRange.Once);
    axis.setGrowBy(new DoubleRange(0.1, 0.1));
    // Set visibleRange to [min data index, max data index]
    axis.setVisibleRange(new DoubleRange(10.0, 50.0));
    
    final CategoryDateAxis axis = sciChartBuilder.newCategoryDateAxis()
            .withAxisAlignment(AxisAlignment.Top)
            .withAutoRangeMode(AutoRange.Once)
            .withGrowBy(0.1, 0.1)
            // Set visibleRange to [min data index, max data index]
            .withVisibleRange(10.0, 50.0)
            .build();
    
    val axis = CategoryDateAxis(context)
    axis.axisAlignment = AxisAlignment.Top
    axis.autoRange = AutoRange.Once
    axis.growBy = DoubleRange(0.1, 0.1)
    // Set visibleRange to [min data index, max data index]
    axis.visibleRange = DoubleRange(10.0, 50.0)
    
    Note

    Note the CategoryDateAxis is treated as a special case. Although it is intended to show Dates, it doesn't allow setting DateRange as VisibleRange. The reason for this is that this axis type works with with data indices, not actual data values. So a DoubleRange should be applied instead, with lower data index as Min and Upper data index as Max.

    To learn more about how to convert values from Dates to Indexes and back, please refer to the Convert Pixels to Data Coordinates article.

    See the Axis Types in action

    Please take a look at the examples from the Android Examples Suite listed below to see these axis types in action:

    • Column Chart with NumericAxis
    • Logarithmic Axis with LogarithmicNumericAxis
    • Fan Chart with DateAxis
    • Candlestick Chart with CategoryDateAxis
    Back to top © 2011-2025 SciChart. All rights reserved. | sitemap.xml