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

0
0

Using MVVM I am trying to force my 2nd Y axis to a specific min and max value. I’m setting the AutoRange to never and the VisibleRange to a DoubleRange(min, max) in my ViewModel in a function named ‘SetAxes(min, max)’.

The behavior seems to be that it works the first time I add a measurement to my chart. On subsequent updates to the chart (when I tell the chart via a method in my model to change it’s axes) it doesn’t update. Here is what I have…

        public void SetAxes(double min, double max)
        {
            RightAxisAutoRange = AutoRange.Never;
            RightAxisVisibleRange = new DoubleRange(min, max);
        }

        // 2nd axis range
        private IRange _rightAxisVisibleRange;
        private AutoRange _rightAxisAutoRange;
        public IRange RightAxisVisibleRange 
        { 
            get { return _rightAxisVisibleRange; }  
            set { SetProperty(ref _rightAxisVisibleRange, value); } 
        }
        public AutoRange RightAxisAutoRange  
        { 
           get { return _rightAxisAutoRange; } 
           set { SetProperty(ref _rightAxisAutoRange, value); } 
       }

       <!-- 2nd Y Axis -->
            <s:NumericAxis AxisTitle="{Binding Path=RightAxisTitle}" 
                           Id="YAxis2"
                           AxisAlignment="Right"
                           Visibility="{Binding Path=RightAxisVisibility}"                               
                           FontFamily="Arial"
                           VisibleRange="{Binding Path=RightAxisVisibleRange}"  
                           AutoRange="{Binding Path=RightAxisAutoRange}"
                           GrowBy="0.1, 0.1" 
                           Style="{DynamicResource ResourceKey=RatioAxisStyle}"
                           s:CursorModifier.AxisLabelContainerStyle="{StaticResource CursorModAxisLabelStyle}"
                           s:CursorModifier.AxisLabelTemplate="{StaticResource CursorModAxisLabelTemplate}" />

Don’t get hung up on the “SetProperty” function in my setters. That’s just an internal mechanism I use in a base class which implements INotifyPropertyChanged.

What I’ve noticed is that the moment I decide to zoom the right Y axis refuses to ever go back to it’s original range. I suppose a way to turn off 2nd Y axis zooming would resolve my problem?

Version
5.2.2.11833
  • Chris Kirkman
    For clarity, I need zooming on the 2nd Y axis to work. I just want it to revert back to the min/max I define when I double click to remove the zoom from the chart. I.e. my first Y axis has autorange which gets me to 0 to 100. My 2nd Y axis is set via the view model as 0 to 2. When I zoom the chart I want to be able to zoom all over the place anywhere from 0 to 100, etc. However when I double click to remove the zoom I want the first Y axis to go back to 0 to 100 and the 2nd Y axis to return to 0 to 2.
  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.