Pre loader

In view model, changing min/max of a shared visible range does not update XAxis.VisibleRange

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

0
0

Hi,

I have several chart panes that share a mouse group and a shared visual range (I inject the shared visual range of type IRange in the constructor of the pane view model). I then set the XAxis visual range to the shared visual range inside each pane view model. However, when I use either of the below approaches outside of the pane view model to adjust the min and max of shared visual range, the Xaxis.VisualRange of each pane does not reflect that change.

Approach A: _sharedVisualRange.Min = ….; _sharedVisualRange.Max = …
Approach B: _sharedVisualRange.SetMinMax(….)

Neither approach actually impacts the XAxis.VisualRange.Min/Max.

Initially when I created the XAxis in code I set its VisualRange equal to the shared visual range that was injected via constructor, like :

XAxis = new CategoryDateTimeAxis()
{
……
……
VisualRange = _sharedVisualRange,
…..
};

Please note that all the above refers to code in the view model. I bind the XAxis in the pane view model to the XAxis of the surface in xaml.

My entire synchronization heavily relies on the assumption of this working, but it does not.

Version
5.xx trial versions
  • You must to post comments
0
0

You’re expecting a single IRange instance to be shared across charts. SciChart doesn’t work like that. When you zoom or pan, or when data updates, SciChart itself can create an IRange instance and set on Axis.VisibleRange. This should be shared with other charts via TwoWay Binding to a common property of type IRange.

To update the shared range across all charts, you simply change the instance of the IRange.

This is the approach used in all our examples. Not sure what you’re doing and why but I would suggest to use the reference implementation.

 <!-- Chart 1-->
  <s:SciChartSurface>
      <s:SciChartSurface.XAxis> 
            <s:CategoryDateTimeAxis VisibleRange="{Binding SharedXRange, Mode=TwoWay}"/>
      </s:SciChartSurface.XAxis>
  </s:SciChartSurface>

 <!-- Chart 2-->
  <s:SciChartSurface>
      <s:SciChartSurface.XAxis> 
            <s:CategoryDateTimeAxis VisibleRange="{Binding SharedXRange, Mode=TwoWay}"/>
      </s:SciChartSurface.XAxis>
  </s:SciChartSurface>

ViewModel

 public class ViewModel 
 {
      // To change range on all charts, set this property to new IRange instance 
      public IRange SharedXRange 
      {
           get => _sharedXRange;
           set 
           {
                _sharedXRange = value;
                OnPropertyChanged("SharedXRange");
           }
      }
 }
  • bbmat
    @Andrew, I am running into the same problem again. Your above suggestion only works when both chart surfaces are binding to the same view model. It definitely breaks badly when creating segregate view model instances for each chart pane. I inject the shared visible range in the constructor of the chart view model. Setting “_sharedXRange = value” breaks the reference and hence sharing between the visual ranges of each view model instance. On the other hand setting the min and max of the shared visible range retains synchronicity but it raises tons of events that are getting fired back and forth between each view model instance’s SharedXRange property and causes a very odd pan behavior. What else can be done when two separate view model instances share reference to a shared visual range ?
  • Andrew Burnett-Thompson
    I’ll say it again, we don’t expect or support that it will be the same range instance across charts, so you’ll have to make it the same instance. In all our examples we bind to a parent ViewModel’s SharedXRange property, not pass the IRange itself into chart panel viewmodels.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.