TimeSpanAxis get not refeshed after panning or zooming

Oystein Bjorke 10 лет назад 0
This discussion was imported from CodePlex

mreu wrote at 2012-10-11 13:56:

Hi

I have a oxyplot (WPF) with some LinearAxis and one TimeSpanAxis. I use MVVM, so I load the data via binding in the corresponding LineSeries. All Axis and Series are defined in the XAML file.

All works well and the TimeSpanAxis gets refresh when I load new values into the oxyplot. But when I pan or zoom the graph and load new data again, the TimeSpanAxis did not get refreshed with the new values, all LineSeries would.

Did I miss something? A call to RefreshPlot() did not change this behavior.

Thanks

Michael


mreu wrote at 2012-10-15 09:29:

Hi

After some more investigations over the weekend I found that my new data replaces the old data, but the graph did not update to the new values in the TimeSpanAxis The TimeSpanAxis shows the same values as before and I had to scroll to the new values. I bind the data in the xaml-file  to the lineseries. The data is a collection of class TimeValue which consist only of a TimeSpan and a double. So, how can I reset the TimeSpanAxis?

This only happens when I scroll or pan the graph and load new data after the panning/scrolling.

This is the xaml code:

    <oxy:Plot Grid.Row="1" LegendPlacement="Outside" LegendPosition="BottomCenter" LegendOrientation="Horizontal" LegendItemSpacing="10" LegendMargin="-15" LegendSymbolLength="20" >
      <oxy:Plot.Axes>
        <oxy:LinearAxis Position="Left" Minimum="0" Maximum="350" Title="Data 1" StartPosition="0" EndPosition="0.5" MajorGridlineStyle="Dot" MinorGridlineStyle="None" MajorStep="50" Key="Data1" AxisTitleDistance="20" />
        <oxy:LinearAxis Position="Left" Minimum="0" Maximum="180" Title="Data 2" StartPosition="0.55" EndPosition="1" MajorGridlineStyle="Dot" MinorGridlineStyle="None" MajorStep="20" Key="Data2"  AxisTitleDistance="20" />
        <oxy:TimeSpanAxis Position="Bottom" StringFormat="hh:mm" MajorGridlineStyle="Dot" />
      </oxy:Plot.Axes>
      <oxy:Plot.Series>
        <oxy:LineSeries ItemsSource="{Binding Data1}" DataFieldX="Time" DataFieldY="Value" StrokeThickness="2" Color="Blue" MarkerType="Diamond" Title="Data 1" YAxisKey="Data1"/>
        <oxy:LineSeries ItemsSource="{Binding Data2}" DataFieldX="Time" DataFieldY="Value" StrokeThickness="2" Color="Green" MarkerType="Square" Title="Data 2" YAxisKey="Data2"/>
      </oxy:Plot.Series>
    </oxy:Plot>

And this is the TimeValue class:
  public class TimeValue {
    public TimeSpan Time { getset; }
    public double Value { getset; }
  }

And this is the property which is bound to the Lineseries:
  private Collection<TimeValuedata1;
  public Collection<TimeValueData1 {
     get { return data1; }
     set {
       if (data1 != value) {
         data1 = value;
         DoPropertyChanged("Data1");
       }
     }
   }
 
  private Collection<TimeValuedata2;
  public Collection<TimeValueData2 {      get { return data2; }      set {        if (data2 != value) {          data2 = value;          DoPropertyChanged("Data2");        }      }    }


mreu wrote at 2012-10-19 08:52:

Is there a function to set the range of what I want to see? i.e. from 5:00 to 7:00 on the horizontal axis.

Thanks

Michael


zixys wrote at 2013-09-07 08:49:

Hello,

I met the same problem here in Winform. After pan or zoom, then if you change the series, the axes seems not to be refreshed.

Thanks.
Jo

zixys wrote at 2013-09-07 09:07:

I found the solution. Just call Reset() on the axis to reset ViewMaximum and ViewMinium after you change the series.

Firefox360x wrote at 2013-11-14 12:19:

Thanks Zixys. Reset() works :D

Сервис поддержки клиентов работает на платформе UserEcho