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.
- You must login to post comments
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
- Yura Khariton answered 5 years ago
-
Thanks.
- You must login to post comments
Please login first to submit.