From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to keep X axis range changes in combination with FitExactly

Solved!
Go to solution

Maybe it's a weird request but I hope there's a good way to handle it.

 

I have a Graph control with X Axis set to Adjuster="FitExactly" and it works beautifully on window initialization.

Thing is, we want to be able to manually adjust X value (by editing the last X value on the Graph X Axis) and keep this value if data is reloaded.  At the monent it's reset due to FitExactly setting.

What would be the best solution for this?

 

Thank you.

0 Kudos
Message 1 of 3
(3,373 Views)
Solution
Accepted by kirko7

The simplest approach might be to use a custom RangeAdjuster implementation that uses the current range until FitExactly returns a different value:


    public sealed class CachedRangeAdjuster : RangeAdjuster {
        private IRange previousRange;

        protected override Range<TData> GetAdjustedRangeCore<TData>( RangeAdjusterArgs<TData> args ) {
            Range<TData> exactRange = FitExactly.GetAdjustedRange<TData>( args );

            Range<TData> result;
            if( object.Equals( previousRange, exactRange ) ) {
                result = args.Range;
            }
            else {
                previousRange = exactRange;
                result = exactRange;
            }

            return result;
        }
    }

~ Paul H
Message 2 of 3
(3,369 Views)

Thanks!

Will try once I get back from vacation.

0 Kudos
Message 3 of 3
(3,353 Views)