Pre loader

Implement a custom Delta Provider

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

Answered
0
0

Hi,

I wanted to implement a custom delta provider for a numeric axis but there is no way to set the delta provider for the numeric axis. Please advice

Note : I want to change the number of ticks shown based on visible range. My visible range is dynamic.

Version
2.2
  • You must to post comments
Best Answer
0
0

Hi Vidya,

Well it isn’t possible to replace default delta generation for NumericTickProvider but you can create a custom TickProvider which extends DeltaTickProvider and pass custom IDeltaCalculator implementation via constructor if you want to create totally different algorithm for delta and tick generation:

  class CustomNumericDeltaProvider implements IDeltaCalculator<Double> {

    @Override
    public IAxisDelta<Double> getDeltaFromRange(Comparable min, Comparable max, int minorsPerMajor, int maxTicks) {
        // implement desired logic here
        return new AxisDelta<>(20d, 100d);
    }
}

class CustomTickProvider extends DeltaTickProvider<CustomNumericDeltaProvider> {

    CustomTickProvider() {
        super(new CustomNumericDeltaProvider());
    }

    @Override
    protected void updateTicks(DoubleValues minorTicks, DoubleValues majorTicks) {
        final double minorDelta = currentMinorDelta;
        final double majorDelta = currentMajorDelta;

        final double min = currentVisibleRangeMin;
        final double max = currentVisibleRangeMax;

        // using min and max + minor/majorDelta fill up minor and major ticks collection
        minorTicks.add(minorTick);
        majorTicks.add(majorTick);
    }
}

xAxis.setTickProvider(new CustomTickProvider());

Is this suitable for your needs?

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