Pre loader

Explicitly set range and tick marks on an Axis

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

Answered
0
0

When displaying a graph in a chart, I would like to set my own range and tickmark values. So when setting a range from -0.15 to 0.65 with the majortickmark set to 0.1, I would like to see Yvalues of 0.65, 0.55, 0.45, 0.35 till -0.15.
When using it now, it will move the axis to display nice round numbers
(see green graph in the attachment).
How can I do this?

Thanks,
Egbert

Images
  • You must to post comments
Best Answer
1
0

Hi,

Ticks generation was improved in the new version, now ticks/labels at edges are shown, also we exposed the TickProvider property on IAxis, which allows to implement custom tick generation algorithm and apply it to axis. To get desired chart behavior, please, try implementing custom TickProvider in the following way:

 public class DoubleTickProvider : TickProvider<double>
    {
        public override double[] GetMinorTicks(IAxisParams axis)
        {
            return GenerateTicks((DoubleRange) axis.VisibleRange, (double)axis.MinorDelta);
        }

        private static double[] GenerateTicks(DoubleRange tickRange, double delta)
        {
            var ticks = new List<double>();
            int i = 0;
            double tick = tickRange.Min;
           
            while (tick<=tickRange.Max)
            {
                tick = tickRange.Min+i*delta;
                ticks.Add(tick);
                i++;
            }
            
            return ticks.ToArray();
        }

        public override double[] GetMajorTicks(IAxisParams axis)
        {
            return GenerateTicks((DoubleRange)axis.VisibleRange, (double)axis.MajorDelta);
        }
    }

Assign its instance to the TickProvider property on axis.

Please, try the above and let us know if it gives you the desired behavior.

Best regards,
Yuriy

  • EJansen
    Hi, This works great! Thanks and best regards, Egbert
  • RTrade A
    Thank you, works!
  • You must to post comments
1
0

Turns out in V3.0 we’ve implemented the Tick provider API:

Using the TickProvider API

In SciChart v3.0 and above, there is now a way to override the exact Tick Intervals.

See this KB article on Advanced Tick Frequency Overriding which introduces the TickProvider API. This allows exact calculation of ticks (Axis Major, Minor gridlines and labels) as the axis is drawn.

Hope this helps!

  • You must to post comments
0
0

Hello Egbert,

The only API we provide to allow customization of tick / gridline intervals is what we’ve discussed already here.

However it seems to me your question is that you want the gridlines to be based off the Green (final) axis, is that correct? If so, then you need to set the property AxisBase.IsPrimaryAxis on that axis, which causes SciChart to use it to generate gridlines.

Is that what you are asking?

Best regards,
Andrew

  • EJansen
    Hi Andrew, In this case it's not about the gridlines itself. We now use annotation lines to draw our own gridlines, because we don't want to change the gridlines when zooming or panning. So the Xaxis is always divided into 12 parts, the Yaxis in 8 parts. The problem now is that the major tickmarks are not set to the range we want to use. If we set a range of 0.63 and -0.17 and a majortickmark of 0.1, we like to see the tickmarks drawn at: 0.63, 0.53, 0.43, 0.33, 0.23, 0.13, 0.03, -0.07, -0.17 This way, the tickmarks are at the same level/height as the fixed gridlines. But no, SciChart creates it own tickmarks and will set them at: 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.0, -0.1, -0.2 at nice rounded number intervals. The problem now is that the tickmarks are not aligned anymore with the fixed gridlines. Is there a way to set my own tickmark range with no nice rounded numbers so they will be aligned with our own fixed grid? Thanks again, Egbert
  • Andrew Burnett-Thompson
    Oh I understand, so basically you need full control over the exact set of ticks (not just the delta's or spacing). Thanks for clarifying! I'm afraid to say the answer is we can't do this yet. While SciChart does provide the ability to specify Major/Minor deltas, there is an internal tick calculation engine which rounds up to "nice" numbers, typically 1, 2, 5 and powers of 10 e.g. 10, 20, 50. This code is deep in the SciChart source and not exposed by any API.
  • deepakb1
    Andrew, Sorry to interrupt this conversation but Is there a way to set Ticks on a CategoryDateTime Axis. I would like the Ticks to be every 5 minutes starting at the top of the hour. I don't see a GetTickCalculator method in the CategoryDateTimeAxis. Is there a way to achieve this ? Thanks, Deepak
  • You must to post comments
Showing 3 results
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