I want a chart to keep the grid lines constant and fix and grid lines doesn’t attached to chart
- abolfazl ghanbari asked 4 years ago
- You must login to post comments
Hi abolfazl ghanbari,
I’m not sure what “grid lines doesn’t attached to chart” mean, but to implement constant positions of gridlines you need to create a custom TickProvider:
class CustomTickProvider extends TickProvider {
@Override
protected void updateTicks(DoubleValues minorTicks, DoubleValues majorTicks) {
final IRange visibleRange = axis.getVisibleRange();
final double min = visibleRange.getMinAsDouble();
final double max = visibleRange.getMaxAsDouble();
final double diff = max - min;
final int maxAutoTicks = axis.getMaxAutoTicks();
final int minorsPerMajor = axis.getMinorsPerMajor();
final double majorStep = diff / maxAutoTicks;
final double minorStep = majorStep / (minorsPerMajor + 1);
double currentMajor = min;
for (int i = 0; i < maxAutoTicks; i++) {
majorTicks.add(currentMajor);
double currentMinor = currentMajor + minorStep;
for (int j = 0; j < minorsPerMajor; j++) {
minorTicks.add(currentMinor);
currentMinor += minorStep;
}
currentMajor += majorStep;
}
majorTicks.add(currentMajor);
}
}
Is this suitable for your needs?
Best regards,
Yura
- Yura Khariton answered 4 years ago
-
I am using this TickProvider but the grid lines vibrate in place. What should I do to solve this problem?
- You must login to post comments
Please login first to submit.