Pre loader

Fixed grid lines

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

0
0

I want a chart to keep the grid lines constant and fix and grid lines doesn’t attached to chart

Version
3.0.0
  • You must to post comments
0
0

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

  • abolfazl ghanbari
    I am using this TickProvider but the grid lines vibrate in place. What should I do to solve this problem?
  • 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