Limiting axis range to limits

Need help in implementing some specific function to your LightningChart Ultimate powered application? Post a question and get code snippets from other LightningChart Ultimate community members.

Moderator: Queue Moderators

Post Reply
SupportArchives
Posts: 16
Joined: Tue Mar 26, 2013 11:01 pm

Limiting axis range to limits

Post by SupportArchives » Thu Jun 06, 2013 1:34 pm

I want to limit the range of X axis between 0 and 20, preventing the user to pan or zoom to beyond those limits. How to achieve that?

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Limiting axis range to limits

Post by ArctionPasi » Thu Jun 06, 2013 1:37 pm

Set RangeChanged event handler for the X Axis:

Code: Select all

void ExamplePointLineSeriesXY_RangeChanged(double newMin, double newMax, AxisBase axis, ref bool cancelRendering)
        {
            double LimitMin = 0; 
            double LimitMax = 20; 

            double dMin = newMin; 
            double dMax = newMax;

            bool bLimited = false;
            if (newMin < LimitMin)
            {
                dMin = LimitMin;
                bLimited = true; 
            }
            if (newMax > LimitMax)
            {
                dMax = LimitMax;
                bLimited = true; 
            }

            if (bLimited)
            {
                cancelRendering = true; //Cancel the ongoing rendering phase 

                axis.SetRange(dMin, dMax); //Render manually here 
            }

        }
LightningChart Support Team, PT

jhyap
Posts: 28
Joined: Tue Apr 16, 2013 12:07 am

Re: Limiting axis range to limits

Post by jhyap » Thu Jun 06, 2013 2:36 pm

I would like to try this on tomorrow. But I do not have Visual Studio to hands on now. So, I would like to ask a real quick question: Where can I find the RangeChange event handler?

Is it find it here?

Code: Select all

lightingChartUltimate1.ViewXY.XAxes[0].here
:D

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Limiting axis range to limits

Post by ArctionPasi » Thu Jun 06, 2013 3:08 pm

Yes, there it is :mrgreen:
LightningChart Support Team, PT

Post Reply