Pre loader

setVisibleRangeLimitMode() on XAxis

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

I have stock charts and want to prevent the user to go beyond the Min/Max datetimes (left, right). I tried applying setVisibleRangeLimitMode() to XAxis but it has no effect:

private final DoubleRange sharedXRange = new DoubleRange();

//sharedXRange.setMinMax(0d, response.body().getData().size()-1d); // not helping
...
final CategoryDateAxis xAxis = sciChartBuilder.newCategoryDateAxis()
        .withVisibility(isMainPane ? View.VISIBLE : View.GONE)
        .withVisibleRange(sharedXRange)
        .withGrowBy(0.1d, 0.1d)
        .build();

xAxis.setMinimalZoomConstrain(10d); // minimum 10 points
xAxis.setVisibleRangeLimitMode(RangeClipMode.MinMax); // not working
//xAxis.setVisibleRangeLimit(new DoubleRange(-5d,5d));
...

I am thinking that maybe I should set Min and Max to sharedXRange, but couldn’t find in the docs what value to put into (tried with index, and Date without luck).

Version
2.x
Images
  • Primoz
    Let me also point out that I am premium user (here it says my Tiral expired??), my order ID is ABT181022-9293-43119.
  • You must to post comments
0
0

Hi Primos,

By default VisibleRangeLimit isn’t applied when you set VisibleRange because we assume that when you set it manually then you know what you’re doing. VisibleRangeLimit is applied during auto range calculations and modifier interaction ( when you scroll, zoom or pan chart ) when VisibleRange is changed indirectly.

If you want to apply VisibleRangeLimit anyway you can create custom axis and override method which checks whether new VisibleRange value satisfies constrains and add check for limit. Then you can override coerceVisibleRange() method which is called when check is failed and apply VisibleRangeLimit constrain there:

    class CustomCategoryDateAxis extends CategoryDateAxis {
    public CustomCategoryDateAxis(Context context) {
        super(context);
    }

    @Override
    protected boolean isZoomConstrainSatisfied(IRange<Double> range) {
        final IRange<Double> limit = getVisibleRangeLimit();

        final boolean isRangeWithinLimit = limit == null || (limit.isValueWithinRange(range.getMin()) && limit.isValueWithinRange(range.getMax()));

        return isRangeWithinLimit && super.isZoomConstrainSatisfied(range);
    }

    @Override
    protected void coerceVisibleRange(IRange<Double> visibleRange) {
        super.coerceVisibleRange(visibleRange);

        tryApplyVisibleRangeLimitTo(visibleRange);
    }
}

Hope this will help you!

Best regards,
Yura

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies