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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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.