SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

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.