Search Results for

    Show / Hide Table of Contents

    Axis Ranging - Get or Set VisibleRange

    How to modify VisibleRange for different Axis Types

    To programmatically range an axis, set the property setVisibleRange(IRange visibleRange).

    Note

    The type of object that needs to be applied to the Axis VisibleRange depends on the axis type.

    For more information about setting VisibleRange on particular Axis type - please see the following:

    • NumericAxis
    • LogarithmicNumericAxis
    • DateAxis
    • CategoryDateAxis

    Adding Padding or Spacing with GrowBy

    Also, it is possible to add spacing to the VisibleRange via the setGrowBy(IRange<Double> growBy) property. It allows to specify two fractions which will be always applied to the min, max values of the axes VisibleRange:

    • Java
    • Java with Builders API
    • Kotlin
    final NumericAxis axis = new NumericAxis(getContext());
    axis.setGrowBy(new DoubleRange(0.1, 0.1));
    axis.setVisibleRange(new DoubleRange(0.0, 10.0));
    
    final NumericAxis axis = sciChartBuilder.newNumericAxis()
            .withGrowBy(0.1, 0.1)
            .withVisibleRange(0.0, 10.0)
            .build();
    
    val axis = NumericAxis(context)
    axis.growBy = DoubleRange(0.1, 0.1)
    axis.visibleRange = DoubleRange(0.0, 10.0)
    

    In the code snippet above, the GrowBy of 0.1 will be applied to the VisibleRange resulting in actual VisibleRange increased by a fraction of 0.1 (10%), i.e. Min = -1, Max = 11.

    GrowBy

    Zooming to fit all the Data

    Sometimes it is required to make an axis to show the full extent of the data associated with it. There are several ways to achieve this in code:

    • set the setVisibleRange(IRange visibleRange) to the getDataRange() value.
    • configure the axis to auto adjust correspondingly to data changes. See the AutoRange article.
    • call the ISciChartController methods from SciChartSurface such as zoomExtents().
    • call the ISciChartController methods from IViewportManager such as zoomExtents().

    To change the VisibleRange by touch interaction with a chart, please read about our ChartModifier APIs.

    Back to top © 2011-2025 SciChart. All rights reserved. | sitemap.xml