Pre loader

Force Y Axis to start at zero

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

1
0

I have a chart that I would like the Y Axis to start at zero but the max size automatically since I don’t know the extent of the values that will be added. How do I do this?

  • You must to post comments
1
0

If you want the YAxis to AutoRange (e.g. always fit the data) but also want YAxis.VisibleRange.Min to always be zero, here is a very simple way to do it.

XAML

        <!-- Create a Y Axis -->
        <SciChart:SciChartSurface.YAxis>
            <SciChart:NumericAxis AutoRange="Always" VisibleRangeChanged="OnVisibleRangeChanged"/>
        </SciChart:SciChartSurface.YAxis>

C#

    private void OnVisibleRangeChanged(object sender, VisibleRangeChangedEventArgs e)
    {
        ((AxisBase)sender).VisibleRange = new DoubleRange(0, e.NewVisibleRange.AsDoubleRange().Max);
    }

That is it!

We also have other techniques (as mentioned) such as VisibleRangeLimit, VisibleRangeLimitMode and the ViewportManager which allow for advanced control over ranges, but the above will work in this case just fine.

Best regards,
Andrew

  • You must to post comments
0
0

Hello there,

Thanks for getting in touch,

Regarding your question, if we’ve got it all in the right way, we can suggest you setting the YAxis VisibleRange to some particular range with Min=0, and AutoRange=”Always” (on YAxis).

Let us know if it does the trick.
If it isn’t suitable for you in any way – please share a screenshot or just more details on the expected behaviour. We’ll be glad to help.

Best regards,
– Olya

  • kelias
    The problem is still occurring but only when all the values are zero. What I want is for zero to always be at the bottom of the chart, a -1 value is not a valid value for this data.
  • You must to post comments
0
0

Hello,

Sorry to interrupt! Olya made me aware of this thread and I wanted to comment. I don’t believe we have a way to do this in the XAML, unless you subclass DefaultViewportManager and override OnCalculateYRange().

We have many examples on using ViewportManager in the forums. It’s a back-door API feature e.g. not something we specifically create examples for but we do suggest it when people need something custom with the VisibleRange on the chart.

I would recommend in the OnCalculateYRange() method in conjunction with AutoRange, returning the current AutoRange result but always change VisibleRange.Min for 0 before returning.

Can you try that and let me know how it goes?

UPDATE 2014:
We’ve introduced the VisibleRangeLimit, VisibleRangeLimitMode properties which allows anchoring VisibleRange and restricting it from going out of the preset range.

Best regards,
Andrew

  • 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