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

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

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.