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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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.